Jenkins Pipeline job can't find script due to @tmp path being created Jenkins Pipeline job can't find script due to @tmp path being created bash bash

Jenkins Pipeline job can't find script due to @tmp path being created


I guess your pwd is not in PATH so you have to call it like this: sh './update-plugins.sh'


Have you tried using the jenkins workspace environment variable WORKSPACE (absolute path of the workspace)? With that your line would look something like this:

sh '${WORKSPACE}/jenkins/pipeline/update-jenkins-plugins-ppln/update-plugins.sh'


I was having the same issue. I think @Oren technically answered your question about why Jenkins creates this tmp space, but I can share some info about how I solved it.

Basically, my Jenkins host symlinks bin/sh to dash; not bash. So, using a POSIX-compliant shell script solved the issue for me.

For example, I was trying to use shopt -s extglob to do some pattern matching:

stage {    def shellCommand = $/ "rm -rf ! (_data|_includes|_plugins|Gemfile|_config.yml|page-builder)"/$    sh(returnStdout: true, script: shellCommand).trim()}

Since dash doesn't support extglob, replacing that with a POSIX-compliant find command worked:

stage {    sh('find . -regextype posix-extended -not -regex ".*includes.*|.*data.*|.*plugins.*|.*config.yml|.*Gemfile.*"')}