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

Superfluous commands for Conditional steps with configure

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • job-dsl-plugin
    • None

      I would like to create a custom builder (using configure) in a Conditional Step.

      job('example') {
        steps {
          conditionalSteps {
            condition {
              stringsMatch('${SOME_PARAMETER}', 'pants', false)
            }
          }
        }
        
        configure { project ->
          project / builders / 'org.jenkinsci.plugins.conditionalbuildstep.ConditionalBuilder' / conditionalbuilders << 'hudson.tasks.Shell' {
      	  command 'echo Hello'
      	}
        }
      }
      

      The resulting config.xml becomes

      <builders>                                                                                                        
             <org.jenkinsci.plugins.conditionalbuildstep.ConditionalBuilder>                                                
                 <runCondition class="org.jenkins_ci.plugins.run_condition.core.StringsMatchCondition">                    
                     <arg1>${SOME_PARAMETER}</arg1>                                                                        
                     <arg2>pants</arg2>                                                                                    
                     <ignoreCase>false</ignoreCase>                                                                        
                 </runCondition>                                                                                            
                 <runner class="org.jenkins_ci.plugins.run_condition.BuildStepRunner$Fail"/>                                
                 <conditionalbuilders>                                                                                      
                     <hudson.tasks.Shell>                                                                                  
                         <command>echo Hello</command>                                                                      
                     </hudson.tasks.Shell>                                                                                  
                     <hudson.tasks.Shell>                                                                                  
                         <command>echo Hello</command>                                                                      
                     </hudson.tasks.Shell>                                                                                  
                     <hudson.tasks.Shell>                                                                                  
                         <command>echo Hello</command>                                                                      
                     </hudson.tasks.Shell>                                                                                  
                 </conditionalbuilders>                                                                                  
             </org.jenkinsci.plugins.conditionalbuildstep.ConditionalBuilder>                                                 </builders>
      

      For some reason 2 superfluous commands are generated. If I change to:

         project / builders / 'org.jenkinsci.plugins.conditionalbuildstep.ConditionalBuilder' / conditionalbuilders / 'hudson.tasks.Shell' {
      

      It works but only allow one step of each type. See discussion https://groups.google.com/forum/#!topic/job-dsl-plugin/MzUMLicGfH4 for more information.

            daspilker Daniel Spilker
            attiand Mattias Andersson
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: