我正在使用一个测试项目来帮助我验证jenkins管道的 PoC 。 它相当简单,由2个不同的节点( master 和 sim )组成。
这是一个VS C ++项目,因此在主节点上,我需要执行:
在 sim节点上,我需要执行:
我几乎可以使用它,只是被卡在sim节点上,出于某种原因,詹金斯正在那里执行代码检出!!我只需要它来获取二进制文件并运行一些测试。不要解决这个问题。
Sim节点无权访问SCM存储库,因为它们不需要处理源代码。
这是我到目前为止使用的声明性管道脚本:
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)]
}
}
}
}
}
Jenkins的工作控制台日志:
...
[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'
答案 0 :(得分:1)
尝试:
options {
skipDefaultCheckout()
}
然后是结帐阶段:
stage('Clone repo') {
steps {
checkout scm
}
}