I want to run the testng.xml file in Jenkins. I am using the custom workspace and I added Execute Shell as a build step.
I am writing the following command to Execute Shell:
java -cp "./*:bin" org.testng.TestNG testng.xml
All the required jar files and testng.xml file is inside /home/wonderbiz/Documents/JarFolder
When I am clicking on build now I am getting this exception.
Run command as a root user or Change the permission of the root directory that you want to access eg here /home/wonderbiz/Documents/JarFolder so use command
$ sudo su
# chmod -R 777 /home
But i would recommend you to create own directory and then modify the permission of that directory. eg
# mkdir /demo
Copy required file to that directory( /demo ) and do the configuration setting then try to run.
This error message...
java.nio.file.AccessDeniedException: /home/wonderbiz/Documents
at sun.nio.fs.UnixException.translateToIOException(UnixException.java:84)
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
at sun.nio.fs.UnixFileSystemProvider.checkAccess(UnixFileSystemProvider.java:308)
at java.nio.file.Files.createDirectories(Files.java:746)
at hudson.FilePath.mkdirs(FilePath.java:3239)
...implies that the Jenkins was unable to access/create the sub-directory /home/wonderbiz/Documents
.
This issue can raise in either/all of the below mentioned cases:
checkAccess
error is generally caused because of either insufficient permissions or someother process locking the file. In this usecase it seems that the folder that Jenkins unsuccessfully tried to access was already present. The folder and all the files beneath were present even before the execution was triggered. Parent directory ( /home/wonderbiz/Documents
) needs to have at least rx
for non-owner to list its content and w
to make changes there, regardless of subdirectory permissions. Change the permission of the /home/wonderbiz/Documents/JarFolder
directory
chmod -R 777 /home
A better approach would have to create dedicated directory eg. in /opt
and use that.
This problem can also ocurr because Jenkins don't have permission to execute job with in /home/wonderbiz/Documents
sub-directory. Go to Jenkins Config file (Red Hat - /etc/sysconfig/jenkins
), and see which user you are using to run Jenkins). To solve this you need to change the owner of jobs to the jenkins user:
sudo chown -R jenkins:jenkins /home/wonderbiz/Documents (need to restart Jenkins)
It appears like the os user which is running jenkins has no write privileges for either the complete workspace directory or some of the files in the workspace directory.
You can find a relevant discussion in Need correct step for Bat file creation using (TestNG.xml + Maven)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.