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

JobDSL "configure" block can be called multiple times

XMLWordPrintable

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

      When using a configure block within a with block, it seems that the configure block may be executed multiple times. For example, I have a job that looks basically like this:

      def job = workflowJob(job_prefix) {            
                  parameters {
                    ...
                  }
                  definition {
                      cpsScm {
                          scm {
                              git {
                                  remote {
                                      url(git_repo)
                                  }
                                  branch(git_branch)
                              }
                          }
                          scriptPath(relative_jenkinsfile)
                      }
                  }
                  logRotator {
                      numToKeep(50)
                  }
              }
      
      job.with {
          out.println("IN JOB.WITH BLOCK")
          triggers {
              scm('H H(21-22) * * 1')
          }
          configure { Node project ->
              out.println("EXECUTING JOB CONFIGURE")
          }
      }
      

      When I run the seed job, I see the IN JOB.WITH BLOCK message only once, but the EXECUTING JOB CONFIGURE message is printed three times.

            daspilker Daniel Spilker
            cprice404 Chris Price
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: