我正在编写我的第一个声明性管道,我想并行运行Git Checkout和Bundler阶段。当这些阶段的步骤并行执行时,我会遇到奇怪的行为。例如:
想出来:在Bitbucket服务器中,您需要手动访问PR页面并刷新“提交缓存”。这样最新的提交就会送到Jenkins。 来源:https://community.atlassian.com/t5/Bitbucket-questions/Change-pull-request-refs-after-Commit-instead-of-after-Approval/qaq-p/194702
bundle install
,并且不会向控制台打印任何内容。此时必须中止构建。代理操作系统:Windows 10 x64
按顺序运行这些步骤会产生预期的结果,一切正常。我不确定我的脚本中缺少什么:
pipeline {
agent {
node {
label "${env.executor_label}"
}
}
stages {
stage('Set Build Name') {
steps {
script {
currentBuild.displayName = "#${env.BUILD_NUMBER} - ${env.app_node} - ${env.browser}@${env.NODE_NAME}"
}
}
} // stage('Set Build Name')
stage('Git Checkout') {
steps {
parallel(
"Git Cucumber-Watir": {
dir('cucumber-watir') {
git(url: 'http://git-repo-url/cucumber-watir.git', branch: 'master', changelog: true)
bat(script: 'git config --add remote.origin.fetch +refs/pull-requests/*/from:refs/remotes/origin/pr/*')
bat(script: 'git fetch origin -p')
bat(script: "git checkout ${env.cucumber_watir_branch}")
}
},
"Git CrModels": {
dir('cr_models') {
git(url: 'http://git-repo-url/cr_models.git', branch: 'master', changelog: true)
bat(script: 'git config --add remote.origin.fetch +refs/pull-requests/*/from:refs/remotes/origin/pr/*')
bat(script: 'git fetch origin -p')
bat(script: "git checkout ${env.cr_models_branch}")
}
},
"Git CaModels": {
dir('ca_models') {
git(url: 'http://git-repo-url/ca_models.git', branch: 'master', changelog: true)
bat(script: 'git config --add remote.origin.fetch +refs/pull-requests/*/from:refs/remotes/origin/pr/*')
bat(script: 'git fetch origin -p')
bat(script: "git checkout ${env.ca_models_branch}")
}
},
"Git CrDbVal": {
dir('cr_dbvals') {
git(url: 'http://git-repo-url/cr_dbvals.git', branch: 'master', changelog: true)
bat(script: 'git config --add remote.origin.fetch +refs/pull-requests/*/from:refs/remotes/origin/pr/*')
bat(script: 'git fetch origin -p')
bat(script: "git checkout ${env.cr_dbvals_branch}")
}
}
) // parallel
} // steps
} // stage('Git Checkout')
stage('Bundler') {
steps {
parallel(
"Bundle Cucumber-Watir": {
dir('cucumber-watir') {
bat(script: "bundle install")
bat(script: "bundle update")
}
},
"Bundle CrModels": {
dir('cr_models') {
bat(script: "bundle install")
bat(script: "bundle update")
}
},
"Bundle CaModels": {
dir('ca_models') {
bat(script: "bundle install")
bat(script: "bundle update")
}
},
"Bundle CrDbVal": {
dir('cr_dbvals') {
bat(script: "bundle install")
bat(script: "bundle update")
}
}
) // parallel
} // steps
} // stage('Bundler')
stage('Execute Test(s)') {
steps {
dir(path: 'cucumber-watir') {
bat 'set NLS_LANG=AMERICAN_AMERICA.WE8ISO8859P1'
bat(script: 'cucumber -t %tags% -f json -o cucumber.json -f pretty --expand')
}
} // steps
} // stage('Execute Test(s)')
} // stages
post {
always {
dir(path: 'cucumber-watir') {
cucumber 'cucumber.json' // Build Cucumber Report
}
deleteDir() // Cleanup
} // always
} // post
} // pipeline