I have the following code inside the pipeline
def deploy(branch='master', repo='xxx'){ if (env.BRANCH_NAME.trim() == branch) { def script = libraryResource 'build/package_indexes/python/build_push.sh' env.PYPI_REPO = repo sh script }else { echo "Not pushing to repo because branch is: "+env.BRANCH_NAME.trim()+" and not "+branch } }
And the script looks like this:
if [ -f "setup.cfg" ]; then # only build a wheel if setup.cfg exists, so we can disable wheel build if need be echo "Build package ${PACKAGE_NAME} tar.gz and wheel, and push to jfrog repo: $PYPI_REPO" python setup.py sdist upload -r jfrog echo "status code: $?" fi
When I run the script directly in the shell:
sh push.sh
It returns status code 1 when it was not possible to click on the repo, see output:
Submitting dist/xxx-xxxx-0.0.7.tar.gz to https://xxx.jfrog.io/xxx/xxx-pypi/ Upload failed (405): Method Not Allowed error: Upload failed (405): Method Not Allowed status code: 1
But when I execute the pipeline in Jenkins, the status code is 0 when it was not possible to click on the repo:
Submitting dist/xxx-xxxx-0.0.7.tar.gz to https://xxx.jfrog.io/xxx/xxx-pypi/ Upload failed (403): Forbidden + echo status code: 0 status code: 0
How can I make status code 1 return if it does not work in Jenkins' job?
UPDATE
It seems the problem is not Jenkins, I can replicate the same problem on the Jenkins server shell.
source share