Viewing Jenkins Jobs' Configuration as XML
Today I've been working with the Jenkins Job DSL plugin, which although great, doesn't provide native bindings for all the properties you'd want.
So I found myself needing to get the raw XML to then apply that using the
configure block. I fortunately had the Job Configuration History plugin to provide the XML handily for me, but I wondered if there was something better.
It turns out that if you have the
Job/ExtendedRead permission, you can simply browse to
/config.xml on a given job. For instance
Job URL: http://localhost:8080/job/production-deploy/ Conig URL: http://localhost:8080/job/production-deploy/config.xml
For some strange reason, it is not possible to set the permission in the Global Security Configuration UI, so you need the Extended Read Permission plugin to expose it in the UI. An alternative is to have the
Confiure permission, but this can be a bit more risky if you want to lock down the ability to change your jobs, especially if you want to be moving to purely Job configuration as code.
But do note that this has the potential to expose configuration or secrets that aren't stored in Jenkins' credentials management, or in a proper secrets management solution, as well job configuration details you do not wish to share.