当我 运行 test.sh 文件时,Jenkins 控制台显示权限被拒绝错误
Jenkins console shows permission denied error when I run the test.sh file
我创建了一个 .sh,其中包含 运行 tesng.XML 文件所需的 java 命令,当我在 Jenkins 上 运行 这个 test.sh 文件时显示权限被拒绝错误。
Jenkins 控制台输出:
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)
Jenkins 使用用户 jenkins
。如果您与其他用户一起创建了文件,则该文件可能存在权限问题。要解决更改文件的权限并允许其他用户执行脚本。您可以使用
chmod +x test.sh
目录 eclipse-workspace
属于 dev2
用户,这里 jenkins
用户正在尝试向其中写入数据。授予 jenkins
对此文件夹的写入权限。尝试
sudo chmod -R a+rw /home/dev2/eclipse-workspace
有关权限的更多详细信息,您可以查看This tutorial
我创建了一个 .sh,其中包含 运行 tesng.XML 文件所需的 java 命令,当我在 Jenkins 上 运行 这个 test.sh 文件时显示权限被拒绝错误。
Jenkins 控制台输出:
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)
Jenkins 使用用户 jenkins
。如果您与其他用户一起创建了文件,则该文件可能存在权限问题。要解决更改文件的权限并允许其他用户执行脚本。您可以使用
chmod +x test.sh
目录 eclipse-workspace
属于 dev2
用户,这里 jenkins
用户正在尝试向其中写入数据。授予 jenkins
对此文件夹的写入权限。尝试
sudo chmod -R a+rw /home/dev2/eclipse-workspace
有关权限的更多详细信息,您可以查看This tutorial