21

i updated Jenkins from apt command line on Ubuntu,i did sudo apt upgrade jenkins immediately after update i am getting this:

jenkins.model.InvalidBuildsDir: ${ITEM_ROOTDIR}/builds does not exist and 
probably cannot be created
at jenkins.model.Jenkins.checkRawBuildsDir(Jenkins.java:3085)
at jenkins.model.Jenkins.loadConfig(Jenkins.java:3009)
Caused: java.io.IOException
at jenkins.model.Jenkins.loadConfig(Jenkins.java:3012)
at jenkins.model.Jenkins.access$1200(Jenkins.java:304)
at jenkins.model.Jenkins$14.run(Jenkins.java:3104)
at org.jvnet.hudson.reactor.TaskGraphBuilder$TaskImpl.run 
(TaskGraphBuilder.java:169)
at org.jvnet.hudson.reactor.Reactor.runTask(Reactor.java:296)
at jenkins.model.Jenkins$5.runTask(Jenkins.java:1068)
at org.jvnet.hudson.reactor.Reactor$2.run(Reactor.java:214)
at org.jvnet.hudson.reactor.Reactor$Node.run(Reactor.java:117)
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:748)
Caused: org.jvnet.hudson.reactor.ReactorException
at org.jvnet.hudson.reactor.Reactor.execute(Reactor.java:282)
at jenkins.InitReactorRunner.run(InitReactorRunner.java:48)
at jenkins.model.Jenkins.executeReactor(Jenkins.java:1102)
at jenkins.model.Jenkins.<init>(Jenkins.java:904)
at hudson.model.Hudson.<init>(Hudson.java:85)
at hudson.model.Hudson.<init>(Hudson.java:81)
at hudson.WebAppMain$3.run(WebAppMain.java:233)
Caused: hudson.util.HudsonFailedToLoad
at hudson.WebAppMain$3.run(WebAppMain.java:250)
chandra
  • 693
  • 3
  • 8
  • 21
  • I have tried to do a system for storing Jenkins backups with just only the config.xml and the /jobs. When trying to replace that files to restore from the backup the exactly same error is thrown. Any solution? – Drubio Jul 04 '18 at 10:23
  • Didn't find any solution, i just had to reinstall Jenkins. – chandra Jul 05 '18 at 13:10

2 Answers2

29

Just found a solution. After update, Jenkins home dir had a mess of files with ubuntu and jenkins owners. I just changed ownership for all of them back to jenkins:

sudo chown -R jenkins:jenkins $JENKINS_HOME
Sergey Yarotskiy
  • 4,536
  • 2
  • 19
  • 27
  • 3
    Just to add in Ubuntu, your `$JENKINS_HOME` directory is often located at `/var/lib/jenkins`, so you could also run the command `sudo chown -R jenkins:jenkins /var/lib/jenkins`. – Promise Preston Apr 24 '21 at 17:26
17

I have experienced this when the $JENKINS_HOME/jobs directory had incorrect permissions or ownership. In my specific case I had rsync'ed jobs to a test server and forgot to update file ownership to match the user Jenkins runs under on the test system. Changing ownership to the correct user resolved the issue.

There are probably a number of reasons why this error can occur, but I would start by reviewing the files and directories under $JENKINS_HOME to verify that the user running the Jenkins process can read and write to them.

Peter Rebholz
  • 503
  • 3
  • 7