Here\'s my Jenkins 2.x pipeline:
node (\'master\'){
stage \'Checkout\'
checkout scm
stage \"Build Pex\"
sh(\'build.sh\')
}
When
I am having the same issue and dir is not helping, possibly because I am working inside a subdirectory of the tmp dir itself (for reason not germane here). My code looks like this
dir(srcDir){
sh 'pwd; la -l; jenkins.sh "build.sh"'
}
(the pwd and la -l statements were added just for debugging. Issue exists w/o them.) With them I get output like:
+ pwd
/jenkins/workspace/aws-perf-test@tmp/repos/2
+ ls -l
total 72
-rw-r--r-- 1 jenkins jenkins 394 May 19 12:20 README.md
drwxr-xr-x 3 jenkins jenkins 4096 May 19 12:20 api-automation
-rwxr-xr-x 1 jenkins jenkins 174 May 19 12:20 build-it.sh
-rwxr-xr-x 1 jenkins jenkins 433 May 19 12:20 build-release.sh
-rwxr-xr-x 1 jenkins jenkins 322 May 19 12:20 build.sh
drwxr-xr-x 3 jenkins jenkins 4096 May 19 12:20 ix-core
drwxr-xr-x 3 jenkins jenkins 4096 May 19 12:20 ix-java-client
drwxr-xr-x 3 jenkins jenkins 4096 May 19 12:20 ix-rest-models
drwxr-xr-x 4 jenkins jenkins 4096 May 19 12:20 ix-service
drwxr-xr-x 7 jenkins jenkins 4096 May 19 12:20 ixternal
drwxr-xr-x 5 jenkins jenkins 4096 May 19 12:20 ixtraneous-stuff
-rwxr-xr-x 1 jenkins jenkins 472 May 19 12:20 jenkins.sh
-rw-r--r-- 1 jenkins jenkins 16847 May 19 12:20 pom.xml
+ jenkins.sh build.sh
/home/jenkins/workspace/aws-perf-test@tmp/repos/2@tmp/durable-a3ec0501/script.sh: line 2: jenkins.sh: command not found
I ultimately did this:
dir(srcDir){
sh 'cdr=$(pwd); $cdr/jenkins.sh "build.sh"'
}