I'm having issue similar to this: How to copy files as Jenkins "post build" action if i don't have privileges to destination directory

I'm willing to move/copy/rsync files from jenkins workspace to


with rights setted to


I've added jenkins to group apache, but the instance of jenkins cannot copy files to /var/www/app.

I've also tried with setting privileges of /var/www/app to apache:jenkins but still, Jenkins keep spitting out error: Permission denied or Operation not permitted

PS: Forgot to add OS is centOS ;)

EDIT 1: This is log from jenkins script runnig:

[workspace] $ /bin/sh -xe /tmp/hudson1379987233097some_more_numbers.sh + sh /path_to_sh_script/script.sh sending incremental file list


rsync: failed to set permissions on "/var/www/app/application": Operation not permitted (1)

And this is the script itself :)


rsync -avzh /path/to/jenkins/jobs/app/workspace/default/application /var/www/app ;

rsync -avzh /path/to/jenkins/jobs/app/workspace/default/library /var/www/app ;

rsync -avzh /path/to/jenkins/jobs/app/workspace/default/public /var/www/app ;

  • Have you checked that directories are group writeable?
    – Karlson
    May 15, 2014 at 16:41
  • @Karlson Thanks for Your idea. But still... those are 0774. And this just doesn't work. :/
    – Mr.TK
    May 18, 2014 at 5:57

3 Answers 3


After a long and fruitful discussion in the comments, and following this link the user managed to solve the problem adding

--no-perms --omit-dir-times

to the rsync options.

Preliminary attempts to solve the issue:

I guess if security does not concern you for a short period of time, you can try

chmod a+rwx /var/www/app 

and then try to write to this directory. Note that if there are subdirectories you must do it recursively with:

chmod --recursive a+rwx /var/www/app 

If it's successful, then you can start removing permissions gradually and this will help you pinpoint the problem.

Verify that the user jenkins is already a group member of apache with

groups apache
  • $ groups apache apache : apache jenkins And i did granted all priviliges to group apache, then after no succes changed it to apache:jeknins and even this didn't help. :(
    – Mr.TK
    May 27, 2014 at 12:00
  • If the "others" have rwx can you write even one file on this directory or not? Your username is small case right? E.g. jenkins and not Jenkins? May 27, 2014 at 12:05
  • Also, if you are using another disk for /var or one of the relevant subdirectories, it is mounted as writable, right? May 27, 2014 at 12:09
  • No :/ rsync: failed to set permissions on "/var/www/app": Operation not permitted (1)
    – Mr.TK
    May 27, 2014 at 12:09
  • 1
    I think this is the problem: superuser.com/questions/299939/… If you have ssh access to the server you can also try compressing your local files, sending them over ssh with scp and then ssh on the server and decompress them there. May 27, 2014 at 12:53

I had a similar issue. I wanted to write to /var/www on localhost in Jenkins. On my server /var/www is owned by www-data, so I added jenkins to www-data group and made /var/www group writable but kept getting permission denied error. Simply restarting jenkins service fixed the issue for me.

  • Same with me, I've been throwing this one around for three hours now, restarted jenkins... and yep.. solved. It's the same as if you add yourself to a group while logged in, you have to log-out then back in for it to take effect, it's no different with jenkins.
    – shawty
    Jan 4, 2021 at 22:44

First add your Linux or apache server to the Jenkin server with SSH with ssh-key exchange . And create an user in linux/apache server with a user as jenkin(unix user). Because if you do ssh for pull/push file jenkin's uses 'jenkin' as standard user.

Add apache user to jenkin group in unix may helpful.

  • Really great thanks for Your answer! Hope it will help and i will be able to give You all this reputation points!! All happens at very same server. :) How to do that on the same server?
    – Mr.TK
    May 23, 2014 at 6:05
  • Do You know or not? :) Bounty is expiring! :) And I cannot accept Your answer without checking if it's correct and I kinda don't know how to! :) Do I have to login via ssh at localhost on user jenkins or apache? Or root-like account? Because both apache and jenkins are "not able to login" accounts.
    – Mr.TK
    May 27, 2014 at 7:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .