-1
我在Jenkins爲自己的公司應用程序使用了自定義插件。將所有Jenkins作業轉換爲DSL腳本時,這意味着我需要使用configure塊來包含使用此插件運行的任務。我以爲我已經正確地編寫了DSL代碼,因爲當我將它輸入http://job-dsl.herokuapp.com/時,它會生成與我當前的作業config.xml完全匹配的XML。但是,當我在Jenkins中運行DSL腳本並生成作業時,它缺少XML的關鍵塊,我無法弄清楚原因。Jenkins dsl配置塊生成的XML不匹配API
我包括在腳本中的配置塊的代碼是:
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 ''
}
和作業的config.xml中產生顯示此:
<org.mycompany.myapp.jenkins.plugin.Builder plugin="[email protected]">
<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>
然而,XML我需要在這個結尾處,以及與我的配置塊中herokuapp顯示的內容相匹配的是:
<org.mycompany.myapp.jenkins.plugin.Builder plugin="[email protected]">
<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>
由於這些是我第一次嘗試使用configure塊,所以我相信我可以用比我所做的更爲簡潔的方式來做到這一點。但是,在操場上測試表明這應該起作用,但是需要運行的任務被排除在生成的XML之外,我無法弄清楚原因。