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

abortAllJobs() for Multijob configured from Job DSL is not working

      Hey guys,

      I'm using the job dsl to configure my jobs. I would like to set the "Abort all other job" option of an phasejob (Multijob) via DSL using the abortAllJobs() function which doesn't work. The corresponding node in the configuration XML persits 'false'.

      Configuration via the Job DSL's configure block works anyway.

      phase("PhaseName") {                         
                                  phaseJob("ConfigurationViaConfigure") { configure configureAbortingPhaseJob() }
                                  phaseJob("UsingDSLFeature") {                                 
                                        abortAllJobs(true)                                  
                                  }                           
      

      Anyone else observed this behaviour?

      Cheers,
      Florian

          [JENKINS-32835] abortAllJobs() for Multijob configured from Job DSL is not working

          I can't reproduce this on Jenkins 1.609 with Multijob 1.20 and Job DSL 1.43-SNAPSHOT.

          My script:

          multiJob('multijob-example') {
            steps {
              phase('PhaseName') {                         
                phaseJob('UsingDSLFeature') {                                 
                  abortAllJobs(true)                                  
                }
              }
            }
          }
          

          The generated XML is:

          <com.tikal.jenkins.plugins.multijob.MultiJobProject plugin='jenkins-multijob-plugin@1.8'>
              <actions></actions>
              <description></description>
              <keepDependencies>false</keepDependencies>
              <properties></properties>
              <scm class='hudson.scm.NullSCM'></scm>
              <canRoam>true</canRoam>
              <disabled>false</disabled>
              <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
              <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
              <triggers class='vector'></triggers>
              <concurrentBuild>false</concurrentBuild>
              <builders>
                  <com.tikal.jenkins.plugins.multijob.MultiJobBuilder>
                      <phaseName>PhaseName</phaseName>
                      <continuationCondition>SUCCESSFUL</continuationCondition>
                      <phaseJobs>
                          <com.tikal.jenkins.plugins.multijob.PhaseJobsConfig>
                              <jobName>UsingDSLFeature</jobName>
                              <currParams>true</currParams>
                              <exposedSCM>true</exposedSCM>
                              <disableJob>false</disableJob>
                              <killPhaseOnJobResultCondition>FAILURE</killPhaseOnJobResultCondition>
                              <abortAllJob>true</abortAllJob>
                              <configs class='java.util.Collections$EmptyList'></configs>
                          </com.tikal.jenkins.plugins.multijob.PhaseJobsConfig>
                      </phaseJobs>
                  </com.tikal.jenkins.plugins.multijob.MultiJobBuilder>
              </builders>
              <publishers></publishers>
              <buildWrappers></buildWrappers>
          </com.tikal.jenkins.plugins.multijob.MultiJobProject>
          

          Daniel Spilker added a comment - I can't reproduce this on Jenkins 1.609 with Multijob 1.20 and Job DSL 1.43-SNAPSHOT. My script: multiJob( 'multijob-example' ) { steps { phase( 'PhaseName' ) { phaseJob( 'UsingDSLFeature' ) { abortAllJobs( true ) } } } } The generated XML is: <com.tikal.jenkins.plugins.multijob.MultiJobProject plugin= 'jenkins-multijob-plugin@1.8' > <actions></actions> <description></description> <keepDependencies> false </keepDependencies> <properties></properties> <scm class= 'hudson.scm.NullSCM' ></scm> <canRoam> true </canRoam> <disabled> false </disabled> <blockBuildWhenDownstreamBuilding> false </blockBuildWhenDownstreamBuilding> <blockBuildWhenUpstreamBuilding> false </blockBuildWhenUpstreamBuilding> <triggers class= 'vector' ></triggers> <concurrentBuild> false </concurrentBuild> <builders> <com.tikal.jenkins.plugins.multijob.MultiJobBuilder> <phaseName>PhaseName</phaseName> <continuationCondition>SUCCESSFUL</continuationCondition> <phaseJobs> <com.tikal.jenkins.plugins.multijob.PhaseJobsConfig> <jobName>UsingDSLFeature</jobName> <currParams> true </currParams> <exposedSCM> true </exposedSCM> <disableJob> false </disableJob> <killPhaseOnJobResultCondition>FAILURE</killPhaseOnJobResultCondition> <abortAllJob> true </abortAllJob> <configs class= 'java.util.Collections$EmptyList' ></configs> </com.tikal.jenkins.plugins.multijob.PhaseJobsConfig> </phaseJobs> </com.tikal.jenkins.plugins.multijob.MultiJobBuilder> </builders> <publishers></publishers> <buildWrappers></buildWrappers> </com.tikal.jenkins.plugins.multijob.MultiJobProject>

          Florian Oeser added a comment -

          Hey Daniel,

          Well okay...using a higher version seems to fix the problem which obviously leads to the point that you can't reproduce it. Go to the DSL Playgound which uses 1.42 like me and the XML doesn't include the corresponding node

          When 1.43 get released?

          Cheers,
          Florian

          Florian Oeser added a comment - Hey Daniel, Well okay...using a higher version seems to fix the problem which obviously leads to the point that you can't reproduce it. Go to the DSL Playgound which uses 1.42 like me and the XML doesn't include the corresponding node When 1.43 get released? Cheers, Florian

          The abortAllJob element is only generated when using version 1.14 or later of the Multijob plugin.

          See https://jenkinsci.github.io/job-dsl-plugin/#method/javaposse.jobdsl.dsl.helpers.step.PhaseJobContext.abortAllJobs and https://github.com/jenkinsci/job-dsl-plugin/blob/job-dsl-1.42/job-dsl-core/src/main/groovy/javaposse/jobdsl/dsl/helpers/step/MultiJobStepContext.groovy#L67.

          The playground does not have any plugin version information, so it does not generate version specific elements.

          Daniel Spilker added a comment - The abortAllJob element is only generated when using version 1.14 or later of the Multijob plugin. See https://jenkinsci.github.io/job-dsl-plugin/#method/javaposse.jobdsl.dsl.helpers.step.PhaseJobContext.abortAllJobs and https://github.com/jenkinsci/job-dsl-plugin/blob/job-dsl-1.42/job-dsl-core/src/main/groovy/javaposse/jobdsl/dsl/helpers/step/MultiJobStepContext.groovy#L67 . The playground does not have any plugin version information, so it does not generate version specific elements.

          Florian Oeser added a comment -

          Okay then we have an explanation for the Playground but as I wrote in the Environment description I'm using Multijob Plugin 1.20 locally (and Job DSL 1.42) too.

          Snippet:

          steps {                            
             phase("Compile.") {
                phaseJob("${buildPrefix}-Compile-FreeBSD-Release") { configure configureAbortingPhaseJob() }
                phaseJob("${buildPrefix}-Compile-Windows-RelWithDebInfo") { 
                   //configure configureAbortingPhaseJob()
                   abortAllJobs(true)  
                 }                             
             }
          }       
          

          leads to this XML for me:

          <com.tikal.jenkins.plugins.multijob.MultiJobProject plugin="jenkins-multijob-plugin@1.20">
            [...]
            <builders>    
          	[...]
                  <com.tikal.jenkins.plugins.multijob.MultiJobBuilder plugin="jenkins-multijob-plugin@1.20">
                    <phaseName>Compile.</phaseName>
                    <phaseJobs>
                      <com.tikal.jenkins.plugins.multijob.PhaseJobsConfig>
                        <jobName>wip_mainline-Compile-FreeBSD-Release</jobName>
                        <currParams>true</currParams>
                        <exposedSCM>true</exposedSCM>
                        <disableJob>false</disableJob>
                        <maxRetries>0</maxRetries>
                        <enableRetryStrategy>false</enableRetryStrategy>
                        <enableCondition>false</enableCondition>
                        <abortAllJob>true</abortAllJob>
                        <configs class="empty-list"/>
                        <killPhaseOnJobResultCondition>FAILURE</killPhaseOnJobResultCondition>
                        <buildOnlyIfSCMChanges>false</buildOnlyIfSCMChanges>
                      </com.tikal.jenkins.plugins.multijob.PhaseJobsConfig>
                      <com.tikal.jenkins.plugins.multijob.PhaseJobsConfig>
                        <jobName>wip_mainline-Compile-Windows-RelWithDebInfo</jobName>
                        <currParams>true</currParams>
                        <exposedSCM>true</exposedSCM>
                        <disableJob>false</disableJob>
                        <maxRetries>0</maxRetries>
                        <enableRetryStrategy>false</enableRetryStrategy>
                        <enableCondition>false</enableCondition>
                        <abortAllJob>false</abortAllJob>
                        <configs class="empty-list"/>
                        <killPhaseOnJobResultCondition>FAILURE</killPhaseOnJobResultCondition>
                        <buildOnlyIfSCMChanges>false</buildOnlyIfSCMChanges>
                      </com.tikal.jenkins.plugins.multijob.PhaseJobsConfig>
                    </phaseJobs>
                    <continuationCondition>SUCCESSFUL</continuationCondition>
                  </com.tikal.jenkins.plugins.multijob.MultiJobBuilder>
              [...]
          </com.tikal.jenkins.plugins.multijob.MultiJobProject>
          

          Florian Oeser added a comment - Okay then we have an explanation for the Playground but as I wrote in the Environment description I'm using Multijob Plugin 1.20 locally (and Job DSL 1.42 ) too. Snippet: steps { phase( "Compile." ) { phaseJob( "${buildPrefix}-Compile-FreeBSD-Release" ) { configure configureAbortingPhaseJob() } phaseJob( "${buildPrefix}-Compile-Windows-RelWithDebInfo" ) { //configure configureAbortingPhaseJob() abortAllJobs( true ) } } } leads to this XML for me: <com.tikal.jenkins.plugins.multijob.MultiJobProject plugin= "jenkins-multijob-plugin@1.20" > [...] <builders> [...] <com.tikal.jenkins.plugins.multijob.MultiJobBuilder plugin= "jenkins-multijob-plugin@1.20" > <phaseName>Compile.</phaseName> <phaseJobs> <com.tikal.jenkins.plugins.multijob.PhaseJobsConfig> <jobName>wip_mainline-Compile-FreeBSD-Release</jobName> <currParams> true </currParams> <exposedSCM> true </exposedSCM> <disableJob> false </disableJob> <maxRetries>0</maxRetries> <enableRetryStrategy> false </enableRetryStrategy> <enableCondition> false </enableCondition> <abortAllJob> true </abortAllJob> <configs class= "empty-list" /> <killPhaseOnJobResultCondition>FAILURE</killPhaseOnJobResultCondition> <buildOnlyIfSCMChanges> false </buildOnlyIfSCMChanges> </com.tikal.jenkins.plugins.multijob.PhaseJobsConfig> <com.tikal.jenkins.plugins.multijob.PhaseJobsConfig> <jobName>wip_mainline-Compile-Windows-RelWithDebInfo</jobName> <currParams> true </currParams> <exposedSCM> true </exposedSCM> <disableJob> false </disableJob> <maxRetries>0</maxRetries> <enableRetryStrategy> false </enableRetryStrategy> <enableCondition> false </enableCondition> <abortAllJob> false </abortAllJob> <configs class= "empty-list" /> <killPhaseOnJobResultCondition>FAILURE</killPhaseOnJobResultCondition> <buildOnlyIfSCMChanges> false </buildOnlyIfSCMChanges> </com.tikal.jenkins.plugins.multijob.PhaseJobsConfig> </phaseJobs> <continuationCondition>SUCCESSFUL</continuationCondition> </com.tikal.jenkins.plugins.multijob.MultiJobBuilder> [...] </com.tikal.jenkins.plugins.multijob.MultiJobProject>

          I can't reproduce this on 1.42. Can you post a complete (but minimal) script which reproduces the problem?

          Daniel Spilker added a comment - I can't reproduce this on 1.42. Can you post a complete (but minimal) script which reproduces the problem?

          Florian Oeser added a comment -

          Hey Daniel,

          thanks for your investigation.

          Well then there's only one more plugin which may cause the issue: The Gradle-Jenkins-Plugin which I'm using to update the Jenkins jobs (defined via DSL). I already looked into the code but I can't see anything which could cause the problem (not applying the 'abortAllJobs' parameter). My minimal example:

          project(':Test') {
              apply plugin: "com.terrafolio.jenkins"
          
              jenkins {
                  servers {
                      testing {
                          [...]
                     }
                }
          
              defaultServer servers.testing
              jobs {
                 "MinimalExample"{
                          type 'Multijob'
                          dsl {
                               steps {      
                                  phase('Third') {
                                    phaseJob('JobA') { abortAllJobs(true) }
                                      phaseJob('JobB')
                                      phaseJob('JobC')
                                  }        
                              }
                          }
                      }
                 }
             }
          }
          

          I'm using the lastest Gradle Jenkins Plugin version 1.3.2 which implicitly uses Job DSL 1.42.

          Thanks in advice,
          Florian

          Florian Oeser added a comment - Hey Daniel, thanks for your investigation. Well then there's only one more plugin which may cause the issue: The Gradle-Jenkins-Plugin which I'm using to update the Jenkins jobs (defined via DSL). I already looked into the code but I can't see anything which could cause the problem (not applying the 'abortAllJobs' parameter). My minimal example: project( ':Test' ) { apply plugin: "com.terrafolio.jenkins" jenkins { servers { testing { [...] } } defaultServer servers.testing jobs { "MinimalExample" { type 'Multijob' dsl { steps { phase( 'Third' ) { phaseJob( 'JobA' ) { abortAllJobs( true ) } phaseJob( 'JobB' ) phaseJob( 'JobC' ) } } } } } } } I'm using the lastest Gradle Jenkins Plugin version 1.3.2 which implicitly uses Job DSL 1.42. Thanks in advice, Florian

          The Gradle Jenkins Plugin has the same limitations as the playground. It does not know which plugin versions are installed in Jenkins, so it can't generate any version specific elements.

          In version 1.43 of Job DSL, the minimum supported version of the Multijob plugin has been increased, so abortAllJob is no longer a version specific element. So if the Gradle Jenkins Plugin updates to 1.43, the element will be generated.

          Daniel Spilker added a comment - The Gradle Jenkins Plugin has the same limitations as the playground. It does not know which plugin versions are installed in Jenkins, so it can't generate any version specific elements. In version 1.43 of Job DSL, the minimum supported version of the Multijob plugin has been increased, so abortAllJob is no longer a version specific element. So if the Gradle Jenkins Plugin updates to 1.43, the element will be generated.

          Florian Oeser added a comment -

          Thanks Daniel for your time and explanation!

          Florian Oeser added a comment - Thanks Daniel for your time and explanation!

            daspilker Daniel Spilker
            foeser Florian Oeser
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: