Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-40074

Unable to add Execute system Groovy script step via DSL

    XMLWordPrintable

Details

    Description

      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 = &apos;nexus&apos;
      
                                                                      String url = &apos;https://mvnrepo.acme-it.com/content/repositories/snapshots/&apos;
      
                                                                      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 = &apos;nexus&apos;
      
                                                                          String url = &apos;https://mvnrepo.acme-it.com/content/repositories/snapshots/&apos;
      
                                                                          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>

      Attachments

        Activity

          When executing the job I only get

          Nov 28, 2016 3:57:00 PM INFO hudson.model.Run execute
          
          acme-Installer-DSL/promotion/Push to Nexus #5 main build action completed: SUCCESS
          
          jbochenski Jakub Bochenski added a comment - When executing the job I only get Nov 28, 2016 3:57:00 PM INFO hudson.model.Run execute acme-Installer-DSL/promotion/Push to Nexus #5 main build action completed: SUCCESS
          oleg_nenashev Oleg Nenashev added a comment -

          No plans to work on it in the middle-term, feel free to take the issue. IMHO right now it is blocked by  JENKINS-34982, as well as other JobDSL support stories.

          oleg_nenashev Oleg Nenashev added a comment - No plans to work on it in the middle-term, feel free to take the issue. IMHO right now it is blocked by  JENKINS-34982 , as well as other JobDSL support stories.

          People

            Unassigned Unassigned
            jbochenski Jakub Bochenski
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: