-
Bug
-
Resolution: Unresolved
-
Blocker
-
None
I tried doing this as a workaround for JENKINS-40022
promotion { name 'Push to Nexus' icon 'star-blue' conditions { manual 'qa' } actions { systemGroovyCommand ''' String id = 'nexus' String url = 'https://mvnrepo.acme-it.com/content/repositories/snapshots/' new hudson.plugins.promoted_builds.tasks.RedeployBatchTaskPublisher(id, url , true) .perform(manager.build, null, manager.listener) ''' } }
Unfortunately if I try to add this step via DSL it's not executed and it doesn't show in WebUI (config page).
There are no errors in Jenkins log during DSL execution.
Nov 28, 2016 3:25:24 PM INFO javaposse.jobdsl.plugin.JenkinsJobManagement createOrUpdateConfig createOrUpdateConfig for acme-Installer-DSL Nov 28, 2016 3:25:24 PM INFO hudson.plugins.promoted_builds.integrations.jobdsl.PromotionsExtensionPoint notifyItemUpdated Updating promotions for acme-Installer-DSL Nov 28, 2016 3:25:24 PM INFO hudson.plugins.promoted_builds.integrations.jobdsl.PromotionsExtensionPoint notifyItemCreated Creating promotions for acme-Installer-DSL Nov 28, 2016 3:25:24 PM INFO hudson.plugins.promoted_builds.integrations.jobdsl.PromotionsExtensionPoint notifyItemCreated Updated promotion with name Release to QA for acme-Installer-DSL Nov 28, 2016 3:25:24 PM INFO hudson.plugins.promoted_builds.integrations.jobdsl.PromotionsExtensionPoint notifyItemCreated Updated promotion with name Push to Nexus for acme-Installer-DSL Nov 28, 2016 3:25:24 PM INFO hudson.plugins.promoted_builds.integrations.jobdsl.PromotionsExtensionPoint notifyItemCreated Reloading config for acme-Installer-DSL
I can add a regular "Execute Groovy script" via DSL by changing systemGroovyCommand to groovyCommand but that's useless.
Adding a "Execute system Groovy script " step manually works fine.
Comparing the manual and DSL-generated config files the most notable difference is lack of plugin="groovy@1.30" attribute on the {{hudson.plugins.groovy.SystemGroovy }} element.
DSL config.xml
<hudson.plugins.promoted__builds.PromotionProcess plugin="promoted-builds@2.27"> <name>Push to Nexus</name> <icon>star-blue</icon> <conditions> <hudson.plugins.promoted__builds.conditions.ManualCondition> <users>qa,engineering</users> <parameterDefinitions/> </hudson.plugins.promoted__builds.conditions.ManualCondition> </conditions> <buildSteps> <hudson.plugins.groovy.SystemGroovy> <bindings></bindings> <classpath></classpath> <scriptSource class="hudson.plugins.groovy.StringScriptSource"> <command> String id = 'nexus' String url = 'https://mvnrepo.acme-it.com/content/repositories/snapshots/' new hudson.plugins.promoted_builds.tasks.RedeployBatchTaskPublisher(id, url , true) .perform(manager.build, null, manager.listener)</command> </scriptSource> </hudson.plugins.groovy.SystemGroovy> </buildSteps> </hudson.plugins.promoted__builds.PromotionProcess>
Manual config.xml
<?xml version='1.0' encoding='UTF-8'?> <hudson.plugins.promoted__builds.PromotionProcess plugin="promoted-builds@2.27"> <keepDependencies>false</keepDependencies> <properties/> <scm class="hudson.scm.NullSCM"/> <canRoam>false</canRoam> <disabled>false</disabled> <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding> <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding> <triggers/> <concurrentBuild>false</concurrentBuild> <conditions> <hudson.plugins.promoted__builds.conditions.ManualCondition> <users>qa,engineering</users> <parameterDefinitions/> </hudson.plugins.promoted__builds.conditions.ManualCondition> </conditions> <icon>star-blue</icon> <isVisible></isVisible> <buildSteps> <hudson.plugins.groovy.SystemGroovy plugin="groovy@1.30"> <scriptSource class="hudson.plugins.groovy.StringScriptSource"> <command> String id = 'nexus' String url = 'https://mvnrepo.acme-it.com/content/repositories/snapshots/' new hudson.plugins.promoted_builds.tasks.RedeployBatchTaskPublisher(id, url , true) .perform(manager.build, null, manager.listener)</command> </scriptSource> <bindings></bindings> <classpath></classpath> </hudson.plugins.groovy.SystemGroovy> </buildSteps> </hudson.plugins.promoted__builds.PromotionProcess>
When executing the job I only get