I am writing a job on a pipeline that calls another script to execute. Jenkins and script files exist in the same directory, but the script cannot be found in the job.
This is the corresponding bit of the script;
stage ('Update') { try { dir('jenkins/pipeline/update-jenkins-plugins-ppln') { sh 'ls -l' sh 'update-plugins.sh' } }
which returns the following error:
[update-jenkins-plugins-ppln] Running shell script + ls -l total 8 -rw-r--r-- 1 jenkins jenkins 2441 Dec 20 09:34 Jenkinsfile -rwxr-xr-x 1 jenkins jenkins 506 Dec 19 14:06 update-plugins.sh [Pipeline] sh [update-jenkins-plugins-ppln] Running shell script + update-plugins.sh /var/lib/jenkins/workspace/update-jenkins-plugins-ppln/jenkins/pipeline/update-jenkins-plugins-ppln@tmp/durable-11cefdd0/script.sh: 2: /var/lib/jenkins/workspace/update-jenkins-plugins-ppln/jenkins/pipeline/update-jenkins-plugins-ppln@tmp/durable-11cefdd0/script.sh: update-plugins.sh: not found
As you can see, the path I'm using is correct because, according to ls file I need update-plugins.sh is in the directory I update-plugins.sh to. For some reason, although when searching for a Jenkins script, @tmp/durable-8d48734f/script.sh added to the path.
Various troubleshooting methods:
- I read that you need to check the branch again, even if you are already checking it to get the Jenkins file, so there I am.
- I have ssh'd in the Jenkins field to check and yes, the script is.
Why is Jenkins adding the @tmp bit, and is there a way to prevent this behavior?
git bash jenkins groovy
Alex
source share