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

earliest git hash passed by parameterized build trigger when downstream job was triggered multiple times

      Job A triggers job B and passes its git hash along. Job A is fast but job B is slow. So there are times when job A finishes and triggers job B while job B is still running and processing the earlier git hash. When job B finishes its current run, the next run would be triggered by multiple runs of job A. The parameterized trigger passes the git hash from the earliest trigger by job A. As a result, git hashes from the later triggers are never processed by job B. The parameterized trigger should pass the git hash from the latest trigger by job A.

          [JENKINS-15160] earliest git hash passed by parameterized build trigger when downstream job was triggered multiple times

          hlau created issue -

          cjo9900 added a comment -

          Which version of jenkins/ parameterized trigger are you using?

          How is Job A configured?
          Is the parameterized trigger done as a post build trigger?
          Are the git hashes parameters passed using "Pass-Through Git commit that was built" Parameters?

          If the answers to above are both yes, then the issue seems to be that the action RevisionParameterAction[1] that the git-plugin is providing via the GitRevisionBuildParameters[2] class does not support the QueueAction[3] interface that would allow the Queue class to add separate builds for the different revisions.

          Alternatively the issue is that the RevisionParameterAction[1] does not implement the FoldableAction[4] interface, that would allow the multiple revisions to be merged together so only the latest revision is passed to the next build, as shown in the Queue Class[5].

          In most use cases the behaviour would want to be trigger the downstream job for every commit Job A built.
          In a smaller number of cases there might be the need for the downstream job to run only for the latest commit in Job A, (not sure how that would work if Job A worked on multiple branches).

          [1] https://github.com/jenkinsci/git-plugin/blob/master/src/main/java/hudson/plugins/git/RevisionParameterAction.java
          [2] https://github.com/jenkinsci/git-plugin/blob/master/src/main/java/hudson/plugins/git/GitRevisionBuildParameters.java
          [3] https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/model/Queue.java#L1467
          [4] https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/model/queue/FoldableAction.java
          [5] https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/model/Queue.java#L526

          cjo9900 added a comment - Which version of jenkins/ parameterized trigger are you using? How is Job A configured? Is the parameterized trigger done as a post build trigger? Are the git hashes parameters passed using "Pass-Through Git commit that was built" Parameters? If the answers to above are both yes, then the issue seems to be that the action RevisionParameterAction [1] that the git-plugin is providing via the GitRevisionBuildParameters [2] class does not support the QueueAction [3] interface that would allow the Queue class to add separate builds for the different revisions. Alternatively the issue is that the RevisionParameterAction [1] does not implement the FoldableAction [4] interface, that would allow the multiple revisions to be merged together so only the latest revision is passed to the next build, as shown in the Queue Class [5] . In most use cases the behaviour would want to be trigger the downstream job for every commit Job A built. In a smaller number of cases there might be the need for the downstream job to run only for the latest commit in Job A, (not sure how that would work if Job A worked on multiple branches). [1] https://github.com/jenkinsci/git-plugin/blob/master/src/main/java/hudson/plugins/git/RevisionParameterAction.java [2] https://github.com/jenkinsci/git-plugin/blob/master/src/main/java/hudson/plugins/git/GitRevisionBuildParameters.java [3] https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/model/Queue.java#L1467 [4] https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/model/queue/FoldableAction.java [5] https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/model/Queue.java#L526
          cjo9900 made changes -
          Assignee Original: huybrechts [ huybrechts ] New: cjo9900 [ cjo9900 ]
          cjo9900 made changes -
          Component/s New: git [ 15543 ]

          hlau added a comment -

          I have experienced this issue in various versions of jenkins and parameterized trigger plugin. I have been upgrading both in the far chance that it might have been fixed from work on other bugs for the plugin. I am now using the latest versions: 1.486 for jenkins and 3.16 for parameterized trigger plugin and I'm still seeing the problem.

          Indeed Job A triggers job B through the post build parameterized trigger plugin using Pass-through Git commit that was built. This is one example of the problem that I saw as recent as in the last hour:

          Job B was triggered by both #414 and #415 of job A:

          Started by upstream project A build number 414
          originally caused by:

          Started by remote host 127.0.0.1
          Started by upstream project A build number 415
          originally caused by:

          Started by remote host 127.0.0.1
          Revision: 495765555ce4db911825ea0b40bca6278669ae72

          Note that the git commit hash of 4957 was actually from #414 of job A:

          Build #414 (Oct 22, 2012 12:28:07 PM)
          ...
          Started by remote host 127.0.0.1

          Revision: 495765555ce4db911825ea0b40bca6278669ae72

          The git commit hash of 4c41 from #415 was not what the triggered job B is building ... in fact, this commit never will get built if no more pushes come in:

          Build #415 (Oct 22, 2012 1:04:17 PM)
          ...
          Revision: 4c41dd60bdff7557133ebfe5229d7f9d06722cef

          As a result, the developers (justifiably) complain that the latest build artifacts often do not reflect the latest push. Since the continuous integration system is broken, I have to continually monitor the jobs and manually kick them when necessary.

          hlau added a comment - I have experienced this issue in various versions of jenkins and parameterized trigger plugin. I have been upgrading both in the far chance that it might have been fixed from work on other bugs for the plugin. I am now using the latest versions: 1.486 for jenkins and 3.16 for parameterized trigger plugin and I'm still seeing the problem. Indeed Job A triggers job B through the post build parameterized trigger plugin using Pass-through Git commit that was built. This is one example of the problem that I saw as recent as in the last hour: Job B was triggered by both #414 and #415 of job A: Started by upstream project A build number 414 originally caused by: Started by remote host 127.0.0.1 Started by upstream project A build number 415 originally caused by: Started by remote host 127.0.0.1 Revision: 495765555ce4db911825ea0b40bca6278669ae72 Note that the git commit hash of 4957 was actually from #414 of job A: Build #414 (Oct 22, 2012 12:28:07 PM) ... Started by remote host 127.0.0.1 Revision: 495765555ce4db911825ea0b40bca6278669ae72 The git commit hash of 4c41 from #415 was not what the triggered job B is building ... in fact, this commit never will get built if no more pushes come in: Build #415 (Oct 22, 2012 1:04:17 PM) ... Revision: 4c41dd60bdff7557133ebfe5229d7f9d06722cef As a result, the developers (justifiably) complain that the latest build artifacts often do not reflect the latest push. Since the continuous integration system is broken, I have to continually monitor the jobs and manually kick them when necessary.

          hlau added a comment -

          Ideally, there would be a checkbox for the user to indicate whether s/he wants every commit built, or just the latest commit built. In my case, job B runs many times slower than job A. If every commit is built, it would take days for job B to catch up. That would mean I would need to manually kill some runs in job B to help it catching up. constant manual intervention is very undesirable.

          hlau added a comment - Ideally, there would be a checkbox for the user to indicate whether s/he wants every commit built, or just the latest commit built. In my case, job B runs many times slower than job A. If every commit is built, it would take days for job B to catch up. That would mean I would need to manually kill some runs in job B to help it catching up. constant manual intervention is very undesirable.

          cjo9900 added a comment -

          Pull request created to solve the issue

          https://github.com/jenkinsci/git-plugin/pull/107

          Includes the option to combine commits, if required.
          The default is to create separate builds for each build triggered with a git hash.

          cjo9900 added a comment - Pull request created to solve the issue https://github.com/jenkinsci/git-plugin/pull/107 Includes the option to combine commits, if required. The default is to create separate builds for each build triggered with a git hash.

          hlau added a comment -

          Thanks. Will this also solve the problem that only the git commit from the earliest trigger in a multiply triggered downstream job gets processed? In my example above, commit 4c41 from #415 never gets built (until I manually kick the job).

          hlau added a comment - Thanks. Will this also solve the problem that only the git commit from the earliest trigger in a multiply triggered downstream job gets processed? In my example above, commit 4c41 from #415 never gets built (until I manually kick the job).

          Code changed in jenkins
          User: cjo9900
          Path:
          src/main/java/hudson/plugins/git/RevisionParameterAction.java
          src/test/java/hudson/plugins/git/RevisionParameterActionTest.java
          http://jenkins-ci.org/commit/git-plugin/0d21dcc3cbfce9e14b117560e11703a267cc0f1f
          Log:
          [FIXED JENKINS-15160] Earliest git hash passed by parameter trigger.

          Correction is to create a seperate build for each git hash rather than
          allowing them to be combined into a single build.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: cjo9900 Path: src/main/java/hudson/plugins/git/RevisionParameterAction.java src/test/java/hudson/plugins/git/RevisionParameterActionTest.java http://jenkins-ci.org/commit/git-plugin/0d21dcc3cbfce9e14b117560e11703a267cc0f1f Log: [FIXED JENKINS-15160] Earliest git hash passed by parameter trigger. Correction is to create a seperate build for each git hash rather than allowing them to be combined into a single build.
          SCM/JIRA link daemon made changes -
          Resolution New: Fixed [ 1 ]
          Status Original: Open [ 1 ] New: Resolved [ 5 ]

            cjo9900 cjo9900
            hlau hlau
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: