0
我想從我的Jenkinsfile中的兩個不同的回購拉特定標籤。標籤是通過從相關管道獲取最新的成功構建並使用這些值確定要簽出哪個標記來確定的。然而,由於SCM沒有替換我添加的withEnv變量,所以我遇到了問題。在下面的代碼,你可以看到我呼應了應該是什麼標籤(這回聲正常工作),但是當涉及到SCM檢查出的標籤LAST_SUCCESSFUL_EXTENSIONS_REPO_BUILD和LAST_SUCCESSFUL_SHARED_REPO_BUILD變量都沒有與他們的價值觀取代拉詹金斯管道中的特定標籤SCM
node {
stage('Checkout') {
withEnv([
"LAST_SUCCESSFUL_EXTENSIONS_REPO_BUILD=${ sh (script: "curl <JENKINS_URL>/job/extensionsrepo/job/${BRANCH_NAME}/lastSuccessfulBuild/buildNumber", returnStdout: true) }",
"LAST_SUCCESSFUL_SHARED_REPO_BUILD=${ sh (script: "curl <JENKINS_URL>/job/sharedrepo/job/${BRANCH_NAME}/lastSuccessfulBuild/buildNumber", returnStdout: true) }"
]) {
sh 'echo ${BRANCH_NAME}_${LAST_SUCCESSFUL_EXTENSIONS_REPO_BUILD}'
sh 'echo ${BRANCH_NAME}_${LAST_SUCCESSFUL_SHARED_REPO_BUILD}'
checkout scm
checkout([
$class: 'GitSCM',
branches: [[name: 'refs/tags/${BRANCH_NAME}_${LAST_SUCCESSFUL_EXTENSIONS_REPO_BUILD}']],
doGenerateSubmoduleConfigurations: false,
extensions: [[
$class: 'RelativeTargetDirectory',
relativeTargetDir: 'app/extensions'
]],
submoduleCfg: [],
userRemoteConfigs: [[
credentialsId: 'ssh-key',
url: '<GIT_URL>'
]]
])
checkout([
$class: 'GitSCM',
branches: [[name: 'refs/tags/${BRANCH_NAME}_${LAST_SUCCESSFUL_SHARED_REPO_BUILD}']],
doGenerateSubmoduleConfigurations: false,
extensions: [[
$class: 'RelativeTargetDirectory',
relativeTargetDir: 'app/shared'
]],
submoduleCfg: [],
userRemoteConfigs: [[
credentialsId: 'ssh-key',
url: '<GIT_URL>'
]]
])
}
}
// test, stage, deploy
}
任何關於我在這裏做錯了什麼指針將不勝感激。毫無疑問,我沒有做到正確,這是愚蠢的。
感謝