Windows Jenkinsfile:如何在另一个节点上部署和运行工件
我正在使用一个测试项目来帮助我验证jenkins管道的PoC。 它相当简单,由两个不同的节点(主节点和sim节点)组成Windows Jenkinsfile:如何在另一个节点上部署和运行工件,windows,jenkins-pipeline,Windows,Jenkins Pipeline,我正在使用一个测试项目来帮助我验证jenkins管道的PoC。 它相当简单,由两个不同的节点(主节点和sim节点)组成 这是一个VS C++项目,因此在主节点< /强>中,我需要执行: 代码校验 建造 归档工件(稍后重用) 运行一些静态代码分析 在sim节点上,我需要执行以下操作: 部署构建工件(从归档阶段开始) 进行一些测试 我几乎成功了,只是卡在sim节点上,不知为什么Jenkins在那里执行代码签出!?我只需要它来获取二进制文件并运行一些测试。你不知道该怎么解决这个问题 Sim节点
这是一个VS C++项目,因此在<强>主节点< /强>中,我需要执行:
- 代码校验
- 建造
- 归档工件(稍后重用)
- 运行一些静态代码分析
- 部署构建工件(从归档阶段开始)
- 进行一些测试
pipeline {
agent {
node {
label 'master'
}
}
environment {
Path = 'C:\\"Program Files (x86)\\Microsoft Visual Studio"\\2017\\Professional\\MSBuild\\15.0\\Bin\\amd64;C:\\Windows\\System32;C:\\local\\boost_1_67_0\\lib64-msvc-14.1;%Path%'
}
stages {
stage('Build') {
steps {
bat 'msbuild "testproj\\testproj.sln" /t:rebuild /p:platform=x64 /p:configuration=Release'
}
}
stage('Archive') {
steps {
archiveArtifacts '**/*.lib, **/*.exe, **/*.xml'
}
}
stage('SCA') {
steps {
bat '"C:\\Program Files\\Cppcheck\\cppcheck" --language=c++ --enable=all --xml --xml-version=2 . 2> cppcheck-result.xml'
publishCppcheck pattern: 'cppcheck-result.xml'
}
}
stage('Test') {
node('Sim') {
steps {
copyArtifacts filter: '**/*.exe', fingerprintArtifacts: true, flatten: true, projectName: 'test', selector: lastSuccessful()
bat 'ut.exe --log_format=XML --log_level=all --log_sink=ut_results.xml'
xunit testTimeMargin: '3000', thresholdMode: 1, thresholds: [], tools: [BoostTest(deleteOutputFiles: true, failIfNotNew: true, pattern: '**/ut_results.xml', skipNoTestFiles: false, stopProcessingIfError: true)]
}
}
}
}
}
詹金斯的作业控制台日志:
...
[Pipeline] publishCppcheck
[Cppcheck] Starting the cppcheck analysis.
[Cppcheck] Processing 1 files with the pattern 'cppcheck-result.xml'.
[Cppcheck] Not changing build status, since no threshold has been exceeded.
[Cppcheck] Ending the cppcheck analysis.
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Test)
[Pipeline] node
Running on Sim in c:\jenkins\workspace\test
[Pipeline] {
[Pipeline] checkout
> git.exe rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> git.exe config remote.origin.url [git repo] # timeout=10
Fetching without tags
...
using GIT_ASKPASS to set credentials
> git.exe fetch --no-tags --progress [git repo] +refs/heads/*:refs/remotes/origin/*
ERROR: Error fetching remote repo 'origin'
尝试:
然后是结帐阶段:
stage('Clone repo') {
steps {
checkout scm
}
}
stage('Clone repo') {
steps {
checkout scm
}
}