1

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

/var/www/app

with rights setted to

apache:apache

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

application/

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

And this is the script itself :)

#!/bin/bash

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 '14 at 16:41
  • @Karlson Thanks for Your idea. But still... those are 0774. And this just doesn't work. :/ – Mr.TK May 18 '14 at 5:57
2
+50

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 '14 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? – Konstantinos May 27 '14 at 12:05
  • Also, if you are using another disk for /var or one of the relevant subdirectories, it is mounted as writable, right? – Konstantinos May 27 '14 at 12:09
  • No :/ rsync: failed to set permissions on "/var/www/app": Operation not permitted (1) – Mr.TK May 27 '14 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. – Konstantinos May 27 '14 at 12:53
1

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.

0

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 '14 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 '14 at 7:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.