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

Two calls to the build function can trigger the same run

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not A Defect
    • Icon: Minor Minor
    • None
    • Jenkins 2.211
      Pipeline: API 2.38
      Pipeline: Build Step 2.11

      I'm not certain which component is responsible for this, so I went with the Pipeline Build Step plugin. When using build to trigger another job, there seems to be a race condition where two calls to the function at approximately the same time with the same target job can both "start" the exact same run. For example, this code (the target job is irrelevant, I just happened to have an empty Freestyle job hanging around to test with):

      parallel (
          First : { build job: "Test/Freestyle", wait: true },
          Second: { build job: "Test/Freestyle", wait: true },
      )
      

      causes the following:

      Branch event
      Obtained Jenkinsfile from 9c8963507d90d9cc4c8acb030efa07ca8a7d8d25
      Running in Durability level: MAX_SURVIVABILITY
      [Pipeline] Start of Pipeline
      [Pipeline] parallel
      [Pipeline] { (Branch: First)
      [Pipeline] { (Branch: Second)
      [Pipeline] build
      Scheduling project: Test » Freestyle
      [Pipeline] build
      Scheduling project: Test » Freestyle
      Starting building: Test » Freestyle #1
      Starting building: Test » Freestyle #1
      [Pipeline] }
      [Pipeline] }
      [Pipeline] // parallel
      [Pipeline] End of Pipeline
      Finished: SUCCESS
      

      Notice that instead of starting Test/Freestyle twice, both branches claim to have started run #1. Adding a sleep in one of the parallel branches fixes it, but I think this can happen any time two jobs happen to try and fork the same target job at the same time.

      This might be the same as JENKINS-55210; I can't tell for sure.

            Unassigned Unassigned
            mrozekma Michael Mrozek
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: