How do I safely retrieve the build root directory of all builds ?
Let's assume that the build directory is configured to be located outside Jenkins Home.
For example, if JENKINS_HOME is /var/jenkins/<instance_name>/JENKINS_HOME, we could have something like /var/jenkins/<instance_name>/jenkinsBuildSata/ or /local/jenkinsBuildData/<instance_name>...
In brief, I don't want to rely of some possible naming rules that could evolve at midterm, and I have not been able to find a Jenkins variable or a Jenkins groovy API.
So, I guess there is a hack that can give that... but which one ?
-
Hi Jean-Luc
You are talking about Build Record Root Directory option in general settings ?
https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/jenkins/model/Jenkins.java#L3660
You can get them from the Jenkins instance
http://javadoc.jenkins.io/jenkins/model/Jenkins.html#getRawBuildsDir--
And then to get the path for a given job you can use
http://javadoc.jenkins.io/jenkins/model/Jenkins.html#getBuildDirFor-hudson.model.Job-
Does it help ?
0 -
Hello Arnaud,
Perhaps it will help... but I am not sure to understand what will return the getRawBuildsDir() api. And its documentation is really discreet...
So, I have to try.
Thanks for the help.
Best Regards.0 -
Hi,
getRawBuildsDir() will return the value you configured in your global settings without expending any variables while getBuildDirFor will compute the path and resolve all variables for a given project
Regards
0 -
Hello Arnaud,
Sorry for such a late answer. I had finally understood what this method returns after some trials.
So, Thanks a lot for having guided me to this method.
I probably already saw it since some times, but had not be curious enough to try to discover what it was for... And I am sure that you will admit that its documentation is really ... how to say ... empty ? ;)
Best Regards
J-L0
Please sign in to leave a comment.
Comments
4 comments