I am keeping a shell script file named urltest.sh
in /var/lib/jenkins
and executing the file from jenkins
build.
When I execute the build, It fails.
The Environment Variables are - HOME - /var/lib/jenkins ; JENKINS_HOME - /var/lib/jenkins
The console output comes as:
Started by user anonymous Building in workspace /var/lib/jenkins/workspace/AutoScript [AutoScript] $ /bin/sh -xe /tmp/hudson2777728063740604479.sh + sh urltest.sh sh: 0: Can't open urltest.sh Build step 'Execute shell' marked build as failure Finished: FAILURE
I am confused where I should keep the shell script file so that it is executed.
On Linux, BSD, and Mac OS (Unix-like) systems, the sh step is used to execute a shell command in a Pipeline.
Based on the number of views this question has, it looks like a lot of people are visiting this to see how to set up a job that executes a shell script.
These are the steps to execute a shell script in Jenkins:
In the textarea you can either paste a script or indicate how to run an existing script. So you can either say:
#!/bin/bash echo "hello, today is $(date)" > /tmp/jenkins_test
or just
/path/to/your/script.sh
Click Save.
Now the newly created job should appear in the main page of Jenkins, together with the other ones. Open it and select Build now to see if it works. Once it has finished pick that specific build from the build history and read the Console output to see if everything happened as desired.
You can get more details in the document Create a Jenkins shell script job in GitHub.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With