To change the jenkins user, open the /etc/sysconfig/jenkins (in debian this file is created in /etc/default) and change the JENKINS_USER to whatever you want. Make sure that user exists in the system (you can check the user in the /etc/passwd file ).
$JENKINS_USER="manula"Then change the ownership of the Jenkins home, Jenkins webroot and logs.
chown -R manula:manula /var/lib/jenkins chown -R manula:manula /var/cache/jenkins chown -R manula:manula /var/log/jenkinsThen restarted the Jenkins jenkins and check the user has changed using a ps command
/etc/init.d/jenkins restart ps -ef | grep jenkins
Thanks a lot! This tutorial helped me a lot!
ReplyDeleteYes Thanks!!! This is what I was missing!
ReplyDeletePerfect! Thanks for the easy solution.
ReplyDeleteI want to run jenkins as user Jenkins, but be able to start/stop/restart it as user jenkins and not as user root. The OS is Linux. Is it possible?
ReplyDeleteYes, It is possible.
DeleteThank you so much Manula! You saved me! :D
ReplyDeleteYes. it worked for me... Thanks.........
ReplyDeleteCool, it works perfectly.....
ReplyDeleteThanks a lot!!!!!
ReplyDeleteGetting Service unavailable 503 error after this change. Not finding logs. What could have broken this?
ReplyDeleteThe only change is changing permission and user. So Check you have the correct permission.
DeleteThanks for the response. I could able to clone in command line with no issues. When i gave root it worked fine. But my id doesnt work. Is other any other place where i could get the logs. I couldnt find it in /var/logs/jenkins/
ReplyDeleteThanks a lot Manula, this really helped and saved my many days!
ReplyDeleteYou're welcome :)
DeleteVery helpful - thank you!
ReplyDeleteI am using an account:group bundlemaker:bundlemaker
When i yum update jenkins, it changes the group back to jenkins for the three directories listed above. Is this something you've seen as well?
I haven't update Jenkins after changing the configuration. So I haven't seen this. I think package manager does this without reading the configuration.
Deletegreat... it helped.. thanks
ReplyDeleteThanks Manula, This doc was very useful. I am new to Jenkins and this helped to meet my deadline. Thanks again.
ReplyDeleteIt works like a charms.
ReplyDeleteThanks a lot!
short super :)
ReplyDeleteThanx a ton :)
This comment has been removed by the author.
ReplyDeleteCheers - saved my day!
ReplyDeleteThank You Manula, saved the day for me.
ReplyDeleteThis helped me a lot too!
ReplyDeleteI was having trouble setting up jenkins permisions and stuff.... but after I read this, it was only a matter of running jenkins as myself!
Thanks!
I don't have root access nor having sudo to the system I'm using. Is there another way to change Jenkins user?
ReplyDeleteIn my situation, I login into Jenkins with my ID. Jenkins know that I am executing the job. However, during the job execution Jenkins use a different ID. Any help with this situation?
Thanks Manula. It helped me a lot.
ReplyDeleteThis saved me a lot of headache with ssh keys!
ReplyDeleteThanks, this saves me a lot of trouble with permission thank you !
ReplyDeleteHow can I give permission if I have Jenkins deployed as docker image
ReplyDeleteHow can I give permission if I have Jenkins deployed as docker image
ReplyDeleteVery helpful instructions.
ReplyDeleteSir, you just nailed it. You have saved my life after 2 days of suffering. Thanks alot and i will keep following for other updates.
ReplyDeleteThank you very much.
ReplyDeleteThanks a lot
ReplyDeletethanks, it works
ReplyDeleteThanks a bunch. I have seen lots of suggestions but yours is the best and the simplest.
ReplyDeletethanks a lot for this valuable commands, its worked for me.
ReplyDeleteGood tip. But can you tell me how I can use the public key of the present user to accept web hooks from a private repository?
ReplyDeleteI tried this on ubuntu LTS version , but failed while restart
ReplyDeleteHey Anish,
DeleteIs there any error on log file?
same here
Deleteme 2
DeleteThanks helped me :)
ReplyDeleteI'm having the below issue after chown to non-jenkins user. While it sounds like permission issue, I'm not clear which permission is required to start jenkins using a different user
ReplyDelete$ /sbin/service jenkins start
Starting Jenkins runuser: cannot set groups: Operation not permitted
[FAILED]
I'm having the below issue after chown to non-jenkins user. While it sounds like permission issue, I'm not clear which permission is required to start jenkins using a different user
ReplyDelete$ /sbin/service jenkins start
Starting Jenkins runuser: cannot set groups: Operation not permitted
[FAILED]
I try above steps what you suggest and when i start jenkins it is running as jenkins user , and i create job it was creating with jenkins user , can you please help me any to run jenkins server on oracle user in oracle cloud
ReplyDeletei tried the above step but its not working for me after restart jenkins service it gives me below error
ReplyDeletejenkins.model.InvalidBuildsDir: ${ITEM_ROOTDIR}/builds does not exist and probably cannot be created
at jenkins.model.Jenkins.checkRawBuildsDir(Jenkins.java:3378)
at jenkins.model.Jenkins.loadConfig(Jenkins.java:3300)
Caused: java.io.IOException
at jenkins.model.Jenkins.loadConfig(Jenkins.java:3303)
at jenkins.model.Jenkins.access$1200(Jenkins.java:340)
at jenkins.model.Jenkins$12.run(Jenkins.java:3398)
at org.jvnet.hudson.reactor.TaskGraphBuilder$TaskImpl.run(TaskGraphBuilder.java:175)
at org.jvnet.hudson.reactor.Reactor.runTask(Reactor.java:305)
at jenkins.model.Jenkins$5.runTask(Jenkins.java:1158)
at org.jvnet.hudson.reactor.Reactor$2.run(Reactor.java:222)
at org.jvnet.hudson.reactor.Reactor$Node.run(Reactor.java:121)
at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:68)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:750)
Caused: org.jvnet.hudson.reactor.ReactorException
I have the exact same problem. Did you ever find a resolution to this?
Delete