绝对詹金斯管道/常规小白这里,我有个阶段詹金斯管道冒泡壳退出代码失败阶段
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 –