-1

I have created one .sh which contains java command required to run the tesng.XML file when I run this test.sh file on Jenkins it shows me permission denied error.

Jenkins console output:

Building in workspace /home/dev2/eclipse-workspace/weeklytask
[weeklytask] $ /bin/sh -xe /tmp/jenkins7439378074963422991.sh
+ ./test.sh
[TestNG] Running:
  /home/dev2/eclipse-workspace/weeklytask/enquiryreminder.xml

Starting ChromeDriver 2.40.565383 (76257d1ab79276b2d53ee976b2c3e3b9f335cde7) on port 8120
Only local connections are allowed.

FOLLOW UP REMINDER CRON WEEKLY CHECK TESTCASE FAILED 
PLEASE CHECK THE TIME INTERVAL SETTING 
SET THE TIME INTERVAL TO 600 
FOLLOW UP REMINDER CRON WEEKLY CHECK TESTCASE FAILED 
PLEASE CHECK THE TIME INTERVAL SETTING 
SET THE TIME INTERVAL TO 600 
[[Utils]] Error while writing to /home/dev2/eclipse-workspace/weeklytask/test-output/Suite/Test.html: /home/dev2/eclipse-workspace/weeklytask/test-output/Suite/Test.html (**Permission denied**)
[[Utils]] Error while writing to /home/dev2/eclipse-workspace/weeklytask/test-output/Suite/Test.xml: /home/dev2/eclipse-workspace/weeklytask/test-output/Suite/Test.xml (Permission denied)

===============================================
Suite
Total tests run: 1, Failures: 1, Skips: 0
===============================================

[[Utils]] Error while writing to test-output/junitreports/TEST-verify.enquiryremindertest.xml: test-output/junitreports/TEST-verify.enquiryremindertest.xml (Permission denied)
peterh
  • 11,875
  • 18
  • 85
  • 108
maruf sayyed
  • 41
  • 1
  • 2
  • 12

1 Answers1

6

Jenkins use the user jenkins. If you have created your file with other user, there might be permission issue on the file. To resolve change the permission on the files and allow other users to execute the script. You can use

chmod +x test.sh

The directory eclipse-workspace belongs to dev2 user and here jenkins user is trying to write data in it. Give jenkins write permission on this folder. try

sudo chmod -R a+rw /home/dev2/eclipse-workspace

For more details about permission you can view This tutorial

Shahzeb Khan
  • 3,582
  • 8
  • 45
  • 79
  • I have used the command given by u the shows following error Building in workspace /home/dev2/eclipse-workspace/weeklytask [weeklytask] $ /bin/sh -xe /tmp/jenkins5356816468432548580.sh + chmod +x maptest.sh chmod: changing permissions of 'maptest.sh': Operation not permitted Build step 'Execute shell' marked build as failure Finished: FAILURE – maruf sayyed Feb 21 '19 at 11:35
  • You need to execute the command not in `jenkins`, but the in console where the file is located. The purpose of the above command is to change the executable permissions of the file by the user who has created the file. It will allow `jenkins` to execute the file then. – Shahzeb Khan Feb 21 '19 at 11:38
  • .sh file getting executed but showing permission denied error to others check error Starting ChromeDriver 2.40.565383 (76257d1ab79276b2d53ee976b2c3e3b9f335cde7) on port 24072 Only local connections are allowed. [[Utils]] Error while writing to /home/dev2/eclipse-workspace/weeklytask/test-output/Suite/Test.html: /home/dev2/eclipse-workspace/weeklytask/test-output/Suite/Test.html (Permission denied) [[Utils]] Error while writing to /home/dev2/eclipse-workspace/weeklytask/test-output/Suite/Test.xml: /home/dev2/eclipse-workspace/weeklytask/test-output/Suite/Test.xml (Permission denied) – maruf sayyed Feb 21 '19 at 11:55
  • the directory `eclipse-workspace` belongs to `dev2` user and here `jenkins` user is trying to write data in it. Give `jenkins` write permission on this folder. try `sudo chmod -R a+rw /home/dev2/eclipse-workspace`. this will give write permissions to users on this folder. – Shahzeb Khan Feb 21 '19 at 13:23