Is there a way to get the info stored in build.xml of a completed build?
I know about $JENKINS_URL/job/JOB/BUILD_ID/api/json but that does not have the same information.
Other than loading from the filesystem $JENKINS_HOME/jobs/JOB/builds/ID/build.xml, is there a way to get it through the api?
I believe you can do build.xml instead of /API/JSON
Pretty curious why you’d need the raw XML though.
This information is the private serialization of a build and is hopefully not accessible via API. What information is missing? Each build participant can make more values public if it makes sense.
I tried $JENKINS_URL/job/JOB/BUILD_ID/build.xml but got 403
build.xml has the full trace of build causes; whereas api/json gives you the build causes just one level above. I know I can get the same info by tracing through the layers but build.xml has all the work done.
build.xml has ‘workspace’ but not api/json. I could get PWD from injectedVars but it’s not always the same as $WORKSPACE.
how would you make $WORKSPACE public?
Look at the parent node of the not accessible data in the build.xml, then you see which plugin stores that information. Create an issue (or even better a PR that adds a corresponding
@Exported annotation) for the affected plugin.
How do I create a PR?
the parent of “workspace” is just “build”
I like to get build/actions/hudson.model.CauseAction too:
Then the property is directly available in the build class:
This file has been truncated.
* The MIT License
* Copyright (c) 2004-2010, Sun Microsystems, Inc., Kohsuke Kawaguchi, Yahoo! Inc., CloudBees, Inc.
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
Please note that this property is not available for pipelines, just for Freestyle jobs.
How do I create a PR?
jenkins/CONTRIBUTING.md at 01b28f3fcca47bfdb49f97ae86fcf30bf9fb37e2 · jenkinsci/jenkins · GitHub
Maybe it helps if you can elaborate
why you want that kind of information?
Lets say a build needs to copy the current workspace of its upstream ancestor. This probably shouldn’t happened in the
Jenkins model but that’s the way it’s been setup in our environment long ago.
I’m trying to get the WORKSPACE of an upstream build, not the current build. Is that possible? Yes I am using Freestyle jobs.