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

Job DSL Can not generate ParameterizedRemoteTrigger parameters correctly

XMLWordPrintable

      I am trying to call a remote Jenkins Job with Parameters and caller Job is generated by Job DSL.

      I used the following Job DSL snippet as it is defined in the Documentation:
      https://jenkinsci.github.io/job-dsl-plugin/#method/javaposse.jobdsl.dsl.helpers.step.StepContext.remoteTrigger

      Note: My local Jenkins Documentation is also same as the one in this general one

      steps {
          remoteTrigger(some-remote-vm, some-job-name) {
              parameter('artifactId', 'example-artifact')
              parameter('classifier', 'win64')
              parameter('extension', 'exe')
              parameter('version', '$releaseVersion')
              blockBuildUntilComplete()
              }
      } 

      As a result in config.xml I get:

      <builders>
          <org.jenkinsci.plugins.ParameterizedRemoteTrigger.RemoteBuildConfiguration>
      ...
          <parameters>
              artifactId=example-artifact classifier=win64 extension=exe version=$releaseVersion
          </parameters>
          <parameterList>
              <string>artifactId=example-artifact</string>
              <string>classifier=win64</string>
              <string>extension=exe</string>
              <string>version=$releaseVersion</string>
          </parameterList>
      ...
      <builders> 

      However this was not visualized in the configuration GUI at all and Job execution has failed because of missing parameters.

      Then I tried to configure the Job with GUI by using map parameters. After Manuel configuration I get following XML part in config.xml:

      <builders>
        <org.jenkinsci.plugins.ParameterizedRemoteTrigger.RemoteBuildConfiguration plugin="Parameterized-Remote-Trigger@3.1.6.3">
          <remoteJenkinsName>some-remote-vm</remoteJenkinsName>
          <parameters2 class="org.jenkinsci.plugins.ParameterizedRemoteTrigger.parameters2.MapParameters">
            <parameters>
              <org.jenkinsci.plugins.ParameterizedRemoteTrigger.parameters2.MapParameter>
                <name>artifactId</name>
                <value>example-artifact</value>
              </org.jenkinsci.plugins.ParameterizedRemoteTrigger.parameters2.MapParameter>
              <org.jenkinsci.plugins.ParameterizedRemoteTrigger.parameters2.MapParameter>
                <name>classifier</name>
                <value>win64</value>
              </org.jenkinsci.plugins.ParameterizedRemoteTrigger.parameters2.MapParameter>
              <org.jenkinsci.plugins.ParameterizedRemoteTrigger.parameters2.MapParameter>
                <name>extension</name>
                <value>exe</value>
              </org.jenkinsci.plugins.ParameterizedRemoteTrigger.parameters2.MapParameter>
              <org.jenkinsci.plugins.ParameterizedRemoteTrigger.parameters2.MapParameter>
                <name>version</name>
                <value>$releaseVersion</value>
              </org.jenkinsci.plugins.ParameterizedRemoteTrigger.parameters2.MapParameter>
            </parameters>
          </parameters2>
      ...
      <builders> 

      As a workaround when I manually generate this "parameters2" Object in the DSL by using custom XML generation then it works, but it is inconsistent with Documentation and inconvenient to reverse engineer it from XML:

      configure { projectNode ->
          def buildersNode = projectNode / builders    buildersNode.'org.jenkinsci.plugins.ParameterizedRemoteTrigger.RemoteBuildConfiguration'.each { pluginNode ->
              pluginNode / blockBuildUntilComplete('true')
              pluginNode / pollInterval('30')
              pluginNode / parameters2(class: 'org.jenkinsci.plugins.ParameterizedRemoteTrigger.parameters2.MapParameters') {
                  parameters {
                      'org.jenkinsci.plugins.ParameterizedRemoteTrigger.parameters2.MapParameter' {
                          name 'artifactId'
                          value 'example-artifact'
                      }
                      'org.jenkinsci.plugins.ParameterizedRemoteTrigger.parameters2.MapParameter' {
                          name 'classifier'
                          value 'win64'
                      }
                      'org.jenkinsci.plugins.ParameterizedRemoteTrigger.parameters2.MapParameter' {
                          name 'extension'
                          value 'exe'
                      }
                      'org.jenkinsci.plugins.ParameterizedRemoteTrigger.parameters2.MapParameter' {
                          name 'version'
                          value '$releaseVersion'
                      }
                  }
              } // parameters2
          }// for each node
      }// configure 

      Can you fix this so it can be generated by Job DSL as described on documentation without reverse engineering?

       

            cashlalala KaiHsiang Chang
            mcancomert Mehmet Can
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: