question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Be able to set "Workspace Root Directory" and "Build Record Root Directory"

See original GitHub issue

I would like to set the two advanced attributes (usually found under `/configure):

image

I have tried the following:

jenkins:
  rawBuildsDir: "${JENKINS_HOME}/var/${ITEM_FULL_NAME}/builds"

But with this I get the following error and stack trace:

SEVERE: Failed ConfigurationAsCode.init
java.lang.Error: java.lang.reflect.InvocationTargetException
        at hudson.init.TaskMethodFinder.invoke(TaskMethodFinder.java:110)
        at hudson.init.TaskMethodFinder$TaskImpl.run(TaskMethodFinder.java:175)
        at org.jvnet.hudson.reactor.Reactor.runTask(Reactor.java:296)
        at jenkins.model.Jenkins$5.runTask(Jenkins.java:1064)
        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 by: java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at hudson.init.TaskMethodFinder.invoke(TaskMethodFinder.java:104)
        ... 8 more
Caused by: java.lang.IllegalArgumentException: Invalid configuration elements for type class hudson.model.Hudson : rawBuildsDir
        at org.jenkinsci.plugins.casc.BaseConfigurator.configure(BaseConfigurator.java:185)
        at org.jenkinsci.plugins.casc.JenkinsConfigurator.configure(JenkinsConfigurator.java:47)
        at org.jenkinsci.plugins.casc.JenkinsConfigurator.configure(JenkinsConfigurator.java:24)
        at org.jenkinsci.plugins.casc.ConfigurationAsCode.configure(ConfigurationAsCode.java:129)
        at org.jenkinsci.plugins.casc.ConfigurationAsCode.configure(ConfigurationAsCode.java:109)
        at org.jenkinsci.plugins.casc.ConfigurationAsCode.init(ConfigurationAsCode.java:95)
        ... 13 more

Mar 18, 2018 12:50:11 PM hudson.util.BootFailure publish
SEVERE: Failed to initialize Jenkins
hudson.util.HudsonFailedToLoad: org.jvnet.hudson.reactor.ReactorException: java.lang.Error: java.lang.reflect.InvocationTargetException
        at hudson.WebAppMain$3.run(WebAppMain.java:250)
Caused by: org.jvnet.hudson.reactor.ReactorException: java.lang.Error: java.lang.reflect.InvocationTargetException
        at org.jvnet.hudson.reactor.Reactor.execute(Reactor.java:282)
        at jenkins.InitReactorRunner.run(InitReactorRunner.java:48)
        at jenkins.model.Jenkins.executeReactor(Jenkins.java:1098)
        at jenkins.model.Jenkins.<init>(Jenkins.java:900)
        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 by: java.lang.Error: java.lang.reflect.InvocationTargetException
        at hudson.init.TaskMethodFinder.invoke(TaskMethodFinder.java:110)
        at hudson.init.TaskMethodFinder$TaskImpl.run(TaskMethodFinder.java:175)
        at org.jvnet.hudson.reactor.Reactor.runTask(Reactor.java:296)
        at jenkins.model.Jenkins$5.runTask(Jenkins.java:1064)
        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 by: java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at hudson.init.TaskMethodFinder.invoke(TaskMethodFinder.java:104)
        ... 8 more
Caused by: java.lang.IllegalArgumentException: Invalid configuration elements for type class hudson.model.Hudson : rawBuildsDir
        at org.jenkinsci.plugins.casc.BaseConfigurator.configure(BaseConfigurator.java:185)
        at org.jenkinsci.plugins.casc.JenkinsConfigurator.configure(JenkinsConfigurator.java:47)
        at org.jenkinsci.plugins.casc.JenkinsConfigurator.configure(JenkinsConfigurator.java:24)
        at org.jenkinsci.plugins.casc.ConfigurationAsCode.configure(ConfigurationAsCode.java:129)
        at org.jenkinsci.plugins.casc.ConfigurationAsCode.configure(ConfigurationAsCode.java:109)
        at org.jenkinsci.plugins.casc.ConfigurationAsCode.init(ConfigurationAsCode.java:95)
        ... 13 more

Mar 18, 2018 12:50:11 PM jenkins.model.Jenkins cleanUp
INFO: Stopping Jenkins

I was initially surprised by rawBuildsDir, and thought it could be the cause, because this attribute is indeed defined only in Jenkins (which Hudson now inherits from). But I guess no, since this is the same for numExecutors and this works…

Any idea if this is a bug, or that I’m misusing the plugin?

Thanks!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:16 (13 by maintainers)

github_iconTop GitHub Comments

5reactions
ashbcommented, Jul 19, 2018

For anyone finding this issue and wondering how to do this: You need to set a system property of jenkins.model.Jenkins.workspacesDir.

The easiest way of doing this is to set this on the command line:

java -Djenkins.model.Jenkins.workspacesDir='/mnt/large/jenkins-workspace/${ITEM_FULL_NAME}' -jar /usr/share/jenkins/jenkins.war

Most ways of running Jenkins (rpm/deb package, docker container etc) have a way of setting JAVA_OPTS so (look in /etc/default or /etc/sysconfig, or an env var to the docker container) depending on which platform you are running on.

(I’m not using CasC directly but was looking to configure from goovy init scripts, which is how I found this issue)

1reaction
jetersencommented, Aug 7, 2019

@tjanson there is no setter for workspaceDir, there is a getter for called: getRawWorkspaceDir

You have to use: -Djenkins.model.Jenkins.workspacesDir as noted by code here https://github.com/jenkinsci/jenkins/blob/17d45ff1ae22a961dedb0b914ffd7ecdfadff005/core/src/main/java/jenkins/model/Jenkins.java#L3090

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to change workspace and build record Root Directory on ...
Navigate to Jenkins -> Manage Jenkins -> Configure System · Right at the top, under Home directory , click the Advanced... · Now...
Read more >
Jenkins: Change Workspaces and Build Directory Locations
Every job in Jenkins has a well “hidden”, I mean really not so obvious, setting to modify the Workspace root location of the...
Read more >
When 'Build Record Root Directory' is enabled, renaming a ...
The 'Build Record Root Directory' (set in configure system, then click Advanced... button at the top), is set to /scratch/jbuildroot/${ITEM_FULLNAME}/builds.
Read more >
Unable to set Workspace Root Directory on Jenkins master on ...
I am able to change the configuration in the 'workspace root directory' field in Manage Jenkins / Configuration but this is not reflected...
Read more >
How To Change Workspace And Build Record Root Directory ...
Navigate to Jenkins->Manage Jenkins->Configure System and click on the Advanced Button on the right hand side. Now you can change your workspace and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found