+1 vote
1 view
in Devops and Agile by (28.1k points)

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.

1 Answer

0 votes
by (48k points)

For this issue, your error message clearly shows that Building in workspace /var/lib/jenkins/workspace/AutoScript but in the question, you have mentioned that urltest.sh is present in /var/lib/jenkins hence this is the reason for your issue if you want to resolve following commands need to do in your build step.

cd             # which will point to /var/lib/jenkins

./urltest.sh   # it will run your script

If it still fails, then try to chown the file as Jenkins user, because you may not have file permission.

For more information on Jenkins, you can join Jenkins Training Course.

Related questions

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...