Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins on Ubuntu - multiple (related) issues

Tags:

jenkins

ubuntu

I'm running Hardy Heron and Jenkins 1.429, installed manually (i.e. downloaded package and installed rather than via the normal instructions here Install Jenkins on Ubuntu due to a 302 error.

Background.. I'm inexperienced with both Ubuntu and Jenkins. I'm tasked with setting up what I'd consider a 'basic' Jenkins CI box to build two Java Maven projects and ultimately a C++ project. We use Synergy CM as the SCM for which I have installed a non-released Synergy plugin for Jenkins (I downloaded the code and built it myself). I currently have no security enabled in Jenkins.

My issue is that when I perform a build, the source code directory tree cannot be accessed (e.g. to delete the target folder during the clean phase). This seems to be because the 'jenkins' user is not the owner of the source directories, but rather my build manager user (the first created Ubuntu user).

How do I resolve this? My thoughts initially are

1. Change ownership of the directory tree

OR

2. Get the users right, i.e. run the jobs as my build manager user who owns the directories. I've read threads about running Jenkins (or jobs) as another user, but I seem to get lost along the way.

3. I can't even see the jenkins user created during the Jenkins package install when I run the user admin tool, but if I try to add a user 'jenkins' it tells me it already exists.

Sorry if this is a newbie question, but would like to know how to go about this correctly. Thanks in advance.

Edit: I run Jenkins as a daemon as per default setup.

Edit 2: "how can the first be grabbing things inaccessible to the second?". I get what you're saying and you're right, I had checked out the code via another user rather than let the jenkins user do it. But I still need to run the build as my build user unless I make the jenkins user just like my build user, which would involve getting a 'jenkins' user created on the UNIX box that runs the Synergy server and probably other things as well. I'd rather just run the build as that user if I can. I've tried adding a line JENKINS_USER=myuser with no luck, and also changing DAEMON_ARGS=--name=jenkins ... to be my user instead of 'jenkins'.

like image 461
codah Avatar asked Dec 17 '22 09:12

codah


1 Answers

Basically you will need to change the JENKINS_USER in the /etc/default/jenkins file as bmargulies said. This sets which user will be used to start jenkins. If you do that and restart jenkins nothing will work though, so you need to run chown on some directories for the new user:

chown -R <user>:<group> /var/run/jenkins/war 
chown <user>:<group> /var/log/jenkins
chown <user>:<group> /etc/init.d/jenkins
chown <user>:<group> /etc/default/jenkins

I think that were all, most important, is that the log has the right permission, so that you can check the log for errors if it does not start up ;-) Bad news is, right now, if you update jenkins from the repository it will overwrite the permissions, and you will have to do the chown dance after every update. I think there is a bug report for this though, so maybe they'll fix it soon.

Hope that helps.

like image 182
pushy Avatar answered Dec 18 '22 23:12

pushy