1

I am trying to run a shell script in jenkins and have given all permissions on the file.

On the run, jenkins mentions the below error

Started by user admin
Building in workspace /var/lib/jenkins/workspace/Test
[Test] $ /bin/sh -xe /tmp/jenkins2660493526195024199.sh
+ /home/admin/Scripts/attest.sh
/tmp/jenkins2660493526195024199.sh: line 2: /home/admin/Scripts/attest.sh: Permission denied
Build step 'Execute shell' marked build as failure
Finished: FAILURE

The file permissions are

[root@prod-server Scripts]# getfacl attest.sh 
# file: attest.sh
# owner: jenkins
# group: jenkins
user::rwx
group::rwx
other::rwx

I am failing to understand why the file is not accessible even though when the file has full permissions. Any suggestions ?

closed as off-topic by sebasth, Jeff Schaller, JigglyNaga, roaima, schily Oct 26 '18 at 14:29

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions describing a problem that can't be reproduced and seemingly went away on its own (or went away when a typo was fixed) are off-topic as they are unlikely to help future readers." – sebasth, JigglyNaga, roaima
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    Check if your /home filesystem is mounted as noexec – zeppelin Jul 18 '17 at 6:03
  • I am not sure if this is correct mount | grep -i /home/ shows nothing – Atul Jul 19 '17 at 4:34
  • ls -ld / /home /home/admin /home/admin/Scripts /home/admin/Scripts/attest.sh please. I suspect one (or more) of those is missing the necessary permissions. – roaima Jul 14 '18 at 14:02
  • Are there any (related) AVC denial messages in /var/log/audit/audit.log? – sebasth Oct 26 '18 at 9:19
0

Recently had a very similar problem with jenkins. Check whether user jenkins has executable access rights on each file in the absolute filepath. That is home, admin, Scripts should as well be available for execution for user jenkins. In case these directories are not owned by jenkins and owned by a group to which jenkins is not added, executable permissions should be granted to other users. Or you can add jenkins to group that owns the file. However, in such case you will have to restart jenkins server in order to reload configuration with new group access for user jenkins.

  • Voters: More like a "maybe this" - type, but I think it is clearly not VLQ candidate. – peterh Feb 9 '18 at 14:21
  • I suggested this too (but as a comment). The OP didn't bother to come back. – roaima Oct 26 '18 at 14:03

Not the answer you're looking for? Browse other questions tagged or ask your own question.