絕對詹金斯管道/常規小白這裏,我有個階段詹金斯管道冒泡殼退出代碼失敗階段
stage('Building and Deploying'){
def build = new Build()
build.deploy()
}
它是使用共享庫,所述Build.groovy
的源是在這裏:
def deploy(branch='master', repo='xxx'){
if (env.BRANCH_NAME.trim() == branch) {
def script = libraryResource 'build/package_indexes/python/build_push.sh'
// TODO: Test out http://stackoverflow.com/questions/40965725/jenkins-pipeline-cps-global-lib-resource-file-for-shell-script-purpose/40994132#40994132
env.PYPI_REPO = repo
sh script
}else {
echo "Not pushing to repo because branch is: "+env.BRANCH_NAME.trim()+" and not "+branch
}
}
問題是當未能將構建推送到遠程回購(見下文)時,舞臺仍然顯示成功。
running upload
Submitting dist/xxx-0.0.7.tar.gz to https://xxx.jfrog.io/xxx/api/pypi/grabone-pypi-local
Upload failed (403): Forbidden
...
Finished: SUCCESS
如何冒充shell腳本的退出代碼並使舞臺失敗?
謝謝,所以一旦我有statusCode,我需要在'deploy'函數中返回它嗎? –
我已經添加了如何將構建標記爲失敗的示例。 – Pom12
酷感謝,我現在有一個不同的問題,現在你可以請看看? http://stackoverflow.com/questions/42475073/jenkins-pipeline-sh-step-not-returning-different-status-code –