I am using a custom made plugin for our own company app in Jenkins. While converting all existing Jenkins jobs to DSL scripts, this means I need to use the configure block to include tasks that are run using this plugin. I thought I had written the DSL code correctly because when I enter it into http://job-dsl.herokuapp.com/, it generates XML which perfectly matches my current config.xml for the job. However, when I run the DSL script in Jenkins and generate a job, it's missing a critical block of the XML and I can't figure out why.
The configure block code I am including in the script is:
configure { project ->
project / 'builders' << 'org.mycompany.myapp.jenkins.plugin.Builder' {
modelOption'modelDownload'
appOption'appZip'
execParameters'-debug'
taskPath 'UnitTests/All.task'
project / 'builders' / 'tasks' << 'org.mycompany.myapp.jenkins.plugin.Builder_-myappTask' {
taskPath 'UnitTests/All.task'
project / 'builders' / 'tasks' / 'parameters'
}
modelPath ''
nexusUrl ''
nexusUser ''
nexusPass ''
myappZipName 'org.mycompany.myapp-win32.win32.x86_64.zip'
}
overwriteMyApp ''
}
And the config.xml of the job being generated shows this:
<org.mycompany.myapp.jenkins.plugin.Builder plugin="myapp-jenkins-plugin@1.0-SNAPSHOT">
<modelOption>modelDownload</modelOption>
<appOption>appZip</appOption>
<modelPath/>
<nexusUrl/>
<nexusUser/>
<nexusPass/>
<myappZipName>org.mycompany.myapp-win32.win32.x86_64.zip</myappZipName>
<execParameters>-debug</execParameters>
<overwritemyappa>false</overwritemyapp>
</org.mycompany.myapp.jenkins.plugin.Builder>
However, the XML I need to have at the end of this is, and which matches what the herokuapp shows me from my configure block, is:
<org.mycompany.myapp.jenkins.plugin.Builder plugin="myapp-jenkins-plugin@1.0-SNAPSHOT">
<modelOption>modelDownload</modelOption>
<appOption>appZip</appOption>
<tasks>
<org.mycompany.myapp.jenkins.plugin.Builder_-myappTask>
<taskPath>UnitTests\All.task</taskPath>
<parameters/>
</org.mycompany.myapp.jenkins.plugin.Builder_-myappTask>
</tasks>
<modelPath/>
<nexusUrl/>
<nexusUser/>
<nexusPass/>
<myappZipName>org.mycompany.myapp-win32.win32.x86_64.zip</myappZipName>
<execParameters>-debug</execParameters>
<overwritemyapp>false</overwritemyapp>
</org.mycompany.myapp.jenkins.plugin.Builder>
As these are my first few attempts at using the configure block, I'm sure I could do this in a far tidier way than what I'm doing. But, testing in the playground indicates this should work, but the task which needs to be run is being left out of the generated XML, and I can't figure out why.