詹金斯管道冒出了shell退出代码以失败舞台 [英] Jenkins pipeline bubble up the shell exit code to fail the stage
本文介绍了詹金斯管道冒出了shell退出代码以失败舞台的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
绝对Jenkins管道/ groovy noob在这里,我有一个阶段
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 =回购
sh脚本
}其他{
回声不推送回购,因为分支是:+ env.BRANCH_NAME.trim )+而不是+分支
}
}
问题是何时未能将构建推向远程回购(见下文),舞台st
运行上传
将dist / xxx-0.0.7.tar.gz提交到https ://xxx.jfrog.io/xxx/api/pypi/grabone-pypi-local
上传失败(403):禁止
...
完成:SUCCESS
如何让shell脚本的退出代码冒出来并且失败?
<解决方案
解决方案
刚刚偶然发现了这个问题,它证明是一个Python版本问题,我不记得Python的确切版本,但它是setuptools中的一个问题, IIRC升级Python到2.7.1x修正了它。
Absolute Jenkins pipeline/groovy noob here, I have a stage
stage('Building and Deploying'){
def build = new Build()
build.deploy()
}
which is using the shared lib, the source of the Build.groovy
is here:
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
}
}
Problem is when failing to push the build to a remote repo (see below), the stage still ends up showing successful.
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
How do I bubble up the exit code of the shell script and fail the stage?
解决方案
Just stumbled onto this question again, it turned out to be a Python version problem, I cannot remember the exact version of the Python but it was a problem within setuptools, IIRC upgrading Python to 2.7.1x fixed it.
这篇关于詹金斯管道冒出了shell退出代码以失败舞台的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文