0
votes

I am trying to copying files from one directory to another directory in Jenkins master machine facing access denied issue while executing in the shell script

cp -a /usr/lib/hook/pm2-logs/. /usr/lib/hook/Hook_Log_Backup/

Issue:

cp: cannot create regular file '/usr/lib/hook/Hook_Log_Backup/./pr_hook_out-0.log': Permission denied cp: cannot create regular file '/usr/lib/hook/Hook_Log_Backup/./pr_hook_err-0.log': Permission denied cp: cannot create regular file '/usr/lib/hook/Hook_Log_Backup/./system_hook_out-1.log': Permission denied cp: cannot create regular file '/usr/lib/hook/Hook_Log_Backup/./system_hook_err-1.log': Permission denied cp: cannot create regular file '/usr/lib/hook/Hook_Log_Backup/./common_hook_out-2.log': Permission denied

1
did you try -rf option or check if permissions for the directory are set to the same value.salsinga

1 Answers

0
votes

You are trying to write to your machine path (/usr/lib/); It means your user running Jenkins does not have write access to that directory (or it's parent directory). If the user running Jenkins has access to do sudo on the machine; you can try it with 'sudo cp'