Could somebody give me a useful link, where I can find information about converting the complex xml configuration for Jenkins jobs?
Here is a Jenkins job example:
<project>
<actions/>
<description>Description</description>
<logRotator class="hudson.tasks.LogRotator">
<!-- ...-->
</logRotator>
<keepDependencies>false</keepDependencies>
<properties>
<hudson.model.ParametersDefinitionProperty/><!-- ...-->
</properties>
<scm class="org.jenkinsci.plugins.multiplescms.MultiSCM" plugin="[email protected]">
<scms>
<hudson.plugins.git.GitSCM plugin="[email protected]"/><!-- ...-->
<hudson.plugins.git.GitSCM plugin="[email protected]"/><!-- ...-->
</scms>
</scm>
<canRoam>true</canRoam>
<disabled>false</disabled>
<blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
<blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
<jdk>Default</jdk>
<triggers>
<hudson.triggers.TimerTrigger/><!-- ...-->
</triggers>
<concurrentBuild>false</concurrentBuild>
<customWorkspace>$HUDSON_WD/$REVISION/checkout</customWorkspace>
<builders/>
<publishers>
<hudson.plugins.globalenvvar.GlobalEnvironmentVariablePublisher plugin="[email protected]"/><!-- ...-->
<hudson.plugins.parameterizedtrigger.BuildTrigger plugin="[email protected]"/><!-- ...-->
<hudson.plugins.templateproject.ProxyPublisher plugin="[email protected]"/><!-- ...-->
</publishers>
<buildWrappers>
<hudson.plugins.timestamper.TimestamperBuildWrapper plugin="[email protected]"/>
</buildWrappers>
</project>
One can view a Jenkins job configuration as XML in the browser by appending config. xml to the end of the URL. For example, if you have the following URL to a Jenkins job https://jenkins.mycompany.com/job/myjob , append config. xml : https://jenkins.mycompany.com/job/myjob/config.xml .
Jenkinsfiles, using a Domain Specific Language (DSL) based on the Groovy programming language, are persistent files that model delivery pipelines 'as code'.
Job DSL was one of the first popular plugins for Jenkins which allows managing configuration as code and many other plugins dealing with this aspect have been created since then, most notably the Jenkins Pipeline and Configuration as Code plugins.
In my experience, it is an entirely manual process of re-writing. Reference material is at https://jenkinsci.github.io/job-dsl-plugin/#.
Many elements in the xml are defaulted, so much of the xml can be skipped. It is only necessary to convert the xml element-by-element if the DSL does not directly support the plugin or feature of the plugin that you have configured.
Conversion process is as follows:
If you're not sure which plugin is providing the job element, you can often see the plugin name in the help-text for that element (click on the little question-mark icon). Otherwise, the xml element often contains the plugin name.
Also good to know is that the job elements are broken out in the same way in the DSL as they are on the Configure screen in Jenkins. So if it is a Trigger, then you can find it in the DSL under triggers.
Simple example (I know, yours is much more complex):
freeStyleJob("Arthur's Example") {
description('Description')
logRotator(30)
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With