James Howell
James Howell

Reputation: 1452

Unix File Permissions issue with Jenkins CI and Github

I am in the process of installing Jenkins to push changes made to a Github repo to a "live" repo on my server. I have installed Jenkins on my Ubuntu server and using its web interface I have installed the Github, Git and Github API plugins. I've also created a build task in Jenkins which runs some shell commands when Github detects that a push has been made to its repo.

The commands are running but I seem to be hitting a permissions issue. I get the following error in the Jenkins Console:

+ git pull origin master
error: cannot open .git/FETCH_HEAD: Permission denied

Build step 'Execute shell' marked build as failure
Finished: FAILURE

The parent directory for the site (and all its subdirectories) is owned by a user "james" who belongs to a group "sudo". Jenkins has its own user "jenkins" who I have since added to the group "sudo". As "jenkins" and "james" are both "sudo" members and the group has permission to write, I am unsure why this error would be occuring?

Upvotes: 1

Views: 933

Answers (1)

VonC
VonC

Reputation: 1328982

Adding a user to the group sudo does not make that user member of the same group as the one protecting the .git folder.

It just allows jenkins or james to be added to the sudoers, and executing commands (specified in said sudoers) as root.

You need to check which group is protecting .git, or if it is the root group, modify the jenkins script in order to sudo git pull origin master.

The OP James Howell confirms in the comments:

I ended up changing the group owner of the directory to "jenkins" of which the jenkins user is already a member.

Upvotes: 1

Related Questions