Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
+1 vote
in DevOps and Agile by (29.3k points)

I am keeping a shell script file named 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/

+ sh

sh: 0: Can't open

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 (50.2k 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 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

./   # 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

Browse Categories