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

Unwanted repetitive builds of the same git commit hash

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Won't Fix
    • git-plugin
    • None

    Description

      In our team we are facing the problem of unwanted repetitive builds of the same commit hash.

      I looked into the sources of git-plugin, switched on verbose logging with "-Dhudson.plugins.git.GitSCM.verbose=true" and found that storing BuildData map of already built branches in build.xml does not work well if the job is configured to run concurrently ("Execute concurrent builds if necessary"). As discussed in https://github.com/jenkinsci/git-plugin/pull/163, saving the map in the job root could solve the problem. However, currently running builds (one or even more) of the job must also be taken into account to prevent single commit to be built several times in a chain.

      Jenkins and plugins versions: 1.532.1, git-plugin 2.0.1, git-client-plugin 1.6.1

      Detailed job setup:

      • maven project - full compilation with all tests
      • job is started via push hook from git (notifyCommit?...&branch=...)
      • Branch specifier matches only master, feature and bugfix branches, but ignores personal and other branches.
        Branch specifier=":origin/(master|bugfix/S14|feature/S14).*"
        It is in regex format because we use name convention for feature/bugfix branches in the form feature/sprint/jiraIssueAndOptionalText, e.g. feature/S14.02/JIRA-123
      • as there are more developers working independently of each other, the job should allow to start concurrent builds as soon as possible after the developer pushes a new branch/commit
      • configured Post-build action "Set build description" to set "${GIT_BRANCH}, ${GIT_COMMIT}" for both success and failed builds

      I tried to prepare a small repository to demonstrate the problem - without success. It seems the problem is related to the size of the repository - when cloning takes longer time.

      We suggest that calls of determineRevisionToBuild and buildData.saveBuild (at least the scheduled commit to build) in hudson.plugins.git.GitSCM#checkout should be as close as possible, before the branch checkout starts (git.checkoutBranch).

      Here it is what happens for a copy of real-size repository (workspace about 1.5GB) with just 4 branches, in a clean new Jenkins job (NotifyCommitTest3), just single push "git/notifyCommit?url=...&branch=master":

      Build History:

      Success > Console Output  #6 	Jan 21, 2014 11:31:17 PM	 13 KB
      	origin/feature/S14.02/stash-jenkins-test, 549bbb10e97a90b1f26db59529ba861797771ccc
      Success > Console Output  #5 	Jan 21, 2014 11:31:12 PM	 12 KB
      	origin/master, 7c98dcefea27ba90f5dc64710fdcd9f128f5ab5c
      Success > Console Output  #4 	Jan 21, 2014 11:31:07 PM	 12 KB
      	origin/master, 7c98dcefea27ba90f5dc64710fdcd9f128f5ab5c
      Success > Console Output  #3 	Jan 21, 2014 11:31:03 PM	 11 KB
      	origin/bugfix/S14.02/stash-jenkins-test, 6fa2f3f32e94997c84c9a49b36c6346565ce8851
      Success > Console Output  #2 	Jan 21, 2014 11:30:09 PM	 11 KB
      	origin/bugfix/S14.02/stash-jenkins-test, 6fa2f3f32e94997c84c9a49b36c6346565ce8851
      Success > Console Output  #1 	Jan 21, 2014 11:28:49 PM	 11 KB
      	origin/bugfix/S14.02/stash-jenkins-test, 6fa2f3f32e94997c84c9a49b36c6346565ce8851
      

      Build #1:

      Started by an SCM change
      [EnvInject] - Loading node environment variables.
      Building remotely on ch06bl09.mgmt.lmc.cz in workspace /srv/jenkins/workspace/NotifyCommitTest3
      Using strategy: Default
      Cloning the remote Git repository
      Cloning repository ssh://git@stash.int.lmc.cz:7999/rec/g2.git
      Fetching upstream changes from ssh://git@stash.int.lmc.cz:7999/rec/g2.git
      Fetching upstream changes from ssh://git@stash.int.lmc.cz:7999/rec/g2.git
      getCandidateRevisions(false,null,,,null,remoteUrls=[ssh://git@stash.int.lmc.cz:7999/rec/g2.git],buildsByBranchName={},lastBuild=null]) considering branches to build
      Seen branch in repository origin/bugfix/S14.02/stash-jenkins-test
      Seen branch in repository origin/feature/S14.02/stash-jenkins-test
      Seen branch in repository origin/master
      Seen branch in repository origin/sprint/g2.2
      Seen 4 remote branches
      Starting with all the branches: [Revision 7c98dcefea27ba90f5dc64710fdcd9f128f5ab5c (origin/master), Revision 549bbb10e97a90b1f26db59529ba861797771ccc (origin/feature/S14.02/stash-jenkins-test), Revision 6fa2f3f32e94997c84c9a49b36c6346565ce8851 (origin/bugfix/S14.02/stash-jenkins-test), Revision a8b7d3421db68823b071ca74f269210718929406 (origin/sprint/g2.2)]
      Ignoring Branch origin/sprint/g2.2(AnyObjectId[a8b7d3421db68823b071ca74f269210718929406]) because it doesn't match branch specifier
      Ignoring Revision a8b7d3421db68823b071ca74f269210718929406 () because we don't care about any of the branches that point to it
      After branch filtering: [Revision 7c98dcefea27ba90f5dc64710fdcd9f128f5ab5c (origin/master), Revision 549bbb10e97a90b1f26db59529ba861797771ccc (origin/feature/S14.02/stash-jenkins-test), Revision 6fa2f3f32e94997c84c9a49b36c6346565ce8851 (origin/bugfix/S14.02/stash-jenkins-test)]
      After non-tip filtering: [Revision 7c98dcefea27ba90f5dc64710fdcd9f128f5ab5c (origin/master), Revision 549bbb10e97a90b1f26db59529ba861797771ccc (origin/feature/S14.02/stash-jenkins-test), Revision 6fa2f3f32e94997c84c9a49b36c6346565ce8851 (origin/bugfix/S14.02/stash-jenkins-test)]
      Removing what's already been built: {}
      After filtering out what's already been built: [Revision 7c98dcefea27ba90f5dc64710fdcd9f128f5ab5c (origin/master), Revision 549bbb10e97a90b1f26db59529ba861797771ccc (origin/feature/S14.02/stash-jenkins-test), Revision 6fa2f3f32e94997c84c9a49b36c6346565ce8851 (origin/bugfix/S14.02/stash-jenkins-test)]
      Multiple candidate revisions
      Scheduling another build to catch up with NotifyCommitTest3
      Checking out Revision 6fa2f3f32e94997c84c9a49b36c6346565ce8851 (origin/bugfix/S14.02/stash-jenkins-test)
      First time build. Skipping changelog.
      Description set: origin/bugfix/S14.02/stash-jenkins-test, 6fa2f3f32e94997c84c9a49b36c6346565ce8851
      Finished: SUCCESS
      

      Build #2 - ignores commit built in #1 and does the same job:

      Started by an SCM change
      [EnvInject] - Loading node environment variables.
      Building remotely on ch06bl09.mgmt.lmc.cz in workspace /srv/jenkins/workspace/NotifyCommitTest3@2
      Using strategy: Default
      Cloning the remote Git repository
      Cloning repository ssh://git@stash.int.lmc.cz:7999/rec/g2.git
      Fetching upstream changes from ssh://git@stash.int.lmc.cz:7999/rec/g2.git
      Fetching upstream changes from ssh://git@stash.int.lmc.cz:7999/rec/g2.git
      getCandidateRevisions(false,null,,,null,remoteUrls=[ssh://git@stash.int.lmc.cz:7999/rec/g2.git],buildsByBranchName={},lastBuild=null]) considering branches to build
      Seen branch in repository origin/bugfix/S14.02/stash-jenkins-test
      Seen branch in repository origin/feature/S14.02/stash-jenkins-test
      Seen branch in repository origin/master
      Seen branch in repository origin/sprint/g2.2
      Seen 4 remote branches
      Starting with all the branches: [Revision 7c98dcefea27ba90f5dc64710fdcd9f128f5ab5c (origin/master), Revision 6fa2f3f32e94997c84c9a49b36c6346565ce8851 (origin/bugfix/S14.02/stash-jenkins-test), Revision 549bbb10e97a90b1f26db59529ba861797771ccc (origin/feature/S14.02/stash-jenkins-test), Revision a8b7d3421db68823b071ca74f269210718929406 (origin/sprint/g2.2)]
      Ignoring Branch origin/sprint/g2.2(AnyObjectId[a8b7d3421db68823b071ca74f269210718929406]) because it doesn't match branch specifier
      Ignoring Revision a8b7d3421db68823b071ca74f269210718929406 () because we don't care about any of the branches that point to it
      After branch filtering: [Revision 7c98dcefea27ba90f5dc64710fdcd9f128f5ab5c (origin/master), Revision 6fa2f3f32e94997c84c9a49b36c6346565ce8851 (origin/bugfix/S14.02/stash-jenkins-test), Revision 549bbb10e97a90b1f26db59529ba861797771ccc (origin/feature/S14.02/stash-jenkins-test)]
      After non-tip filtering: [Revision 7c98dcefea27ba90f5dc64710fdcd9f128f5ab5c (origin/master), Revision 6fa2f3f32e94997c84c9a49b36c6346565ce8851 (origin/bugfix/S14.02/stash-jenkins-test), Revision 549bbb10e97a90b1f26db59529ba861797771ccc (origin/feature/S14.02/stash-jenkins-test)]
      Removing what's already been built: {}
      After filtering out what's already been built: [Revision 7c98dcefea27ba90f5dc64710fdcd9f128f5ab5c (origin/master), Revision 6fa2f3f32e94997c84c9a49b36c6346565ce8851 (origin/bugfix/S14.02/stash-jenkins-test), Revision 549bbb10e97a90b1f26db59529ba861797771ccc (origin/feature/S14.02/stash-jenkins-test)]
      Multiple candidate revisions
      Scheduling another build to catch up with NotifyCommitTest3
      Checking out Revision 6fa2f3f32e94997c84c9a49b36c6346565ce8851 (origin/bugfix/S14.02/stash-jenkins-test)
      Description set: origin/bugfix/S14.02/stash-jenkins-test, 6fa2f3f32e94997c84c9a49b36c6346565ce8851
      Finished: SUCCESS
      

      Build #3:

      Started by an SCM change
      [EnvInject] - Loading node environment variables.
      Building remotely on ch06bl09.mgmt.lmc.cz in workspace /srv/jenkins/workspace/NotifyCommitTest3
      Using strategy: Default
      Fetching changes from the remote Git repository
      Fetching upstream changes from ssh://git@stash.int.lmc.cz:7999/rec/g2.git
      getCandidateRevisions(false,null,,,null,remoteUrls=[ssh://git@stash.int.lmc.cz:7999/rec/g2.git],buildsByBranchName={},lastBuild=null]) considering branches to build
      Seen branch in repository origin/bugfix/S14.02/stash-jenkins-test
      Seen branch in repository origin/feature/S14.02/stash-jenkins-test
      Seen branch in repository origin/master
      Seen branch in repository origin/sprint/g2.2
      Seen 4 remote branches
      Starting with all the branches: [Revision 7c98dcefea27ba90f5dc64710fdcd9f128f5ab5c (origin/master), Revision 6fa2f3f32e94997c84c9a49b36c6346565ce8851 (origin/bugfix/S14.02/stash-jenkins-test), Revision 549bbb10e97a90b1f26db59529ba861797771ccc (origin/feature/S14.02/stash-jenkins-test), Revision a8b7d3421db68823b071ca74f269210718929406 (origin/sprint/g2.2)]
      Ignoring Branch origin/sprint/g2.2(AnyObjectId[a8b7d3421db68823b071ca74f269210718929406]) because it doesn't match branch specifier
      Ignoring Revision a8b7d3421db68823b071ca74f269210718929406 () because we don't care about any of the branches that point to it
      After branch filtering: [Revision 7c98dcefea27ba90f5dc64710fdcd9f128f5ab5c (origin/master), Revision 6fa2f3f32e94997c84c9a49b36c6346565ce8851 (origin/bugfix/S14.02/stash-jenkins-test), Revision 549bbb10e97a90b1f26db59529ba861797771ccc (origin/feature/S14.02/stash-jenkins-test)]
      After non-tip filtering: [Revision 7c98dcefea27ba90f5dc64710fdcd9f128f5ab5c (origin/master), Revision 6fa2f3f32e94997c84c9a49b36c6346565ce8851 (origin/bugfix/S14.02/stash-jenkins-test), Revision 549bbb10e97a90b1f26db59529ba861797771ccc (origin/feature/S14.02/stash-jenkins-test)]
      Removing what's already been built: {}
      After filtering out what's already been built: [Revision 7c98dcefea27ba90f5dc64710fdcd9f128f5ab5c (origin/master), Revision 6fa2f3f32e94997c84c9a49b36c6346565ce8851 (origin/bugfix/S14.02/stash-jenkins-test), Revision 549bbb10e97a90b1f26db59529ba861797771ccc (origin/feature/S14.02/stash-jenkins-test)]
      Multiple candidate revisions
      Scheduling another build to catch up with NotifyCommitTest3
      Checking out Revision 6fa2f3f32e94997c84c9a49b36c6346565ce8851 (origin/bugfix/S14.02/stash-jenkins-test)
      First time build. Skipping changelog.
      Description set: origin/bugfix/S14.02/stash-jenkins-test, 6fa2f3f32e94997c84c9a49b36c6346565ce8851
      Finished: SUCCESS
      

      Build #4 - skips the already-built-commit for the first time:

      Started by an SCM change
      [EnvInject] - Loading node environment variables.
      Building remotely on ch06bl09.mgmt.lmc.cz in workspace /srv/jenkins/workspace/NotifyCommitTest3
      Using strategy: Default
      Last Built Revision: Revision 6fa2f3f32e94997c84c9a49b36c6346565ce8851 (origin/bugfix/S14.02/stash-jenkins-test)
      Fetching changes from the remote Git repository
      Fetching upstream changes from ssh://git@stash.int.lmc.cz:7999/rec/g2.git
      getCandidateRevisions(false,null,,,null,remoteUrls=[ssh://git@stash.int.lmc.cz:7999/rec/g2.git],buildsByBranchName={origin/bugfix/S14.02/stash-jenkins-test=Build #3 of Revision 6fa2f3f32e94997c84c9a49b36c6346565ce8851 (origin/bugfix/S14.02/stash-jenkins-test)},lastBuild=Build #3 of Revision 6fa2f3f32e94997c84c9a49b36c6346565ce8851 (origin/bugfix/S14.02/stash-jenkins-test)]) considering branches to build
      Seen branch in repository origin/bugfix/S14.02/stash-jenkins-test
      Seen branch in repository origin/feature/S14.02/stash-jenkins-test
      Seen branch in repository origin/master
      Seen branch in repository origin/sprint/g2.2
      Seen 4 remote branches
      Starting with all the branches: [Revision 7c98dcefea27ba90f5dc64710fdcd9f128f5ab5c (origin/master), Revision 6fa2f3f32e94997c84c9a49b36c6346565ce8851 (origin/bugfix/S14.02/stash-jenkins-test), Revision 549bbb10e97a90b1f26db59529ba861797771ccc (origin/feature/S14.02/stash-jenkins-test), Revision a8b7d3421db68823b071ca74f269210718929406 (origin/sprint/g2.2)]
      Ignoring Branch origin/sprint/g2.2(AnyObjectId[a8b7d3421db68823b071ca74f269210718929406]) because it doesn't match branch specifier
      Ignoring Revision a8b7d3421db68823b071ca74f269210718929406 () because we don't care about any of the branches that point to it
      After branch filtering: [Revision 7c98dcefea27ba90f5dc64710fdcd9f128f5ab5c (origin/master), Revision 6fa2f3f32e94997c84c9a49b36c6346565ce8851 (origin/bugfix/S14.02/stash-jenkins-test), Revision 549bbb10e97a90b1f26db59529ba861797771ccc (origin/feature/S14.02/stash-jenkins-test)]
      After non-tip filtering: [Revision 7c98dcefea27ba90f5dc64710fdcd9f128f5ab5c (origin/master), Revision 6fa2f3f32e94997c84c9a49b36c6346565ce8851 (origin/bugfix/S14.02/stash-jenkins-test), Revision 549bbb10e97a90b1f26db59529ba861797771ccc (origin/feature/S14.02/stash-jenkins-test)]
      Removing what's already been built: {origin/bugfix/S14.02/stash-jenkins-test=Build #3 of Revision 6fa2f3f32e94997c84c9a49b36c6346565ce8851 (origin/bugfix/S14.02/stash-jenkins-test)}
      After filtering out what's already been built: [Revision 7c98dcefea27ba90f5dc64710fdcd9f128f5ab5c (origin/master), Revision 549bbb10e97a90b1f26db59529ba861797771ccc (origin/feature/S14.02/stash-jenkins-test)]
      Multiple candidate revisions
      Scheduling another build to catch up with NotifyCommitTest3
      Checking out Revision 7c98dcefea27ba90f5dc64710fdcd9f128f5ab5c (origin/master)
      First time build. Skipping changelog.
      Description set: origin/master, 7c98dcefea27ba90f5dc64710fdcd9f128f5ab5c
      Finished: SUCCESS
      

      Build #5:

      Started by an SCM change
      [EnvInject] - Loading node environment variables.
      Building remotely on ch06bl09.mgmt.lmc.cz in workspace /srv/jenkins/workspace/NotifyCommitTest3@2
      Using strategy: Default
      Last Built Revision: Revision 6fa2f3f32e94997c84c9a49b36c6346565ce8851 (origin/bugfix/S14.02/stash-jenkins-test)
      Fetching changes from the remote Git repository
      Fetching upstream changes from ssh://git@stash.int.lmc.cz:7999/rec/g2.git
      getCandidateRevisions(false,null,,,null,remoteUrls=[ssh://git@stash.int.lmc.cz:7999/rec/g2.git],buildsByBranchName={origin/bugfix/S14.02/stash-jenkins-test=Build #3 of Revision 6fa2f3f32e94997c84c9a49b36c6346565ce8851 (origin/bugfix/S14.02/stash-jenkins-test)},lastBuild=Build #3 of Revision 6fa2f3f32e94997c84c9a49b36c6346565ce8851 (origin/bugfix/S14.02/stash-jenkins-test)]) considering branches to build
      Seen branch in repository origin/bugfix/S14.02/stash-jenkins-test
      Seen branch in repository origin/feature/S14.02/stash-jenkins-test
      Seen branch in repository origin/master
      Seen branch in repository origin/sprint/g2.2
      Seen 4 remote branches
      Starting with all the branches: [Revision 7c98dcefea27ba90f5dc64710fdcd9f128f5ab5c (origin/master), Revision 6fa2f3f32e94997c84c9a49b36c6346565ce8851 (origin/bugfix/S14.02/stash-jenkins-test), Revision 549bbb10e97a90b1f26db59529ba861797771ccc (origin/feature/S14.02/stash-jenkins-test), Revision a8b7d3421db68823b071ca74f269210718929406 (origin/sprint/g2.2)]
      Ignoring Branch origin/sprint/g2.2(AnyObjectId[a8b7d3421db68823b071ca74f269210718929406]) because it doesn't match branch specifier
      Ignoring Revision a8b7d3421db68823b071ca74f269210718929406 () because we don't care about any of the branches that point to it
      After branch filtering: [Revision 7c98dcefea27ba90f5dc64710fdcd9f128f5ab5c (origin/master), Revision 6fa2f3f32e94997c84c9a49b36c6346565ce8851 (origin/bugfix/S14.02/stash-jenkins-test), Revision 549bbb10e97a90b1f26db59529ba861797771ccc (origin/feature/S14.02/stash-jenkins-test)]
      After non-tip filtering: [Revision 7c98dcefea27ba90f5dc64710fdcd9f128f5ab5c (origin/master), Revision 6fa2f3f32e94997c84c9a49b36c6346565ce8851 (origin/bugfix/S14.02/stash-jenkins-test), Revision 549bbb10e97a90b1f26db59529ba861797771ccc (origin/feature/S14.02/stash-jenkins-test)]
      Removing what's already been built: {origin/bugfix/S14.02/stash-jenkins-test=Build #3 of Revision 6fa2f3f32e94997c84c9a49b36c6346565ce8851 (origin/bugfix/S14.02/stash-jenkins-test)}
      After filtering out what's already been built: [Revision 7c98dcefea27ba90f5dc64710fdcd9f128f5ab5c (origin/master), Revision 549bbb10e97a90b1f26db59529ba861797771ccc (origin/feature/S14.02/stash-jenkins-test)]
      Multiple candidate revisions
      Scheduling another build to catch up with NotifyCommitTest3
      Checking out Revision 7c98dcefea27ba90f5dc64710fdcd9f128f5ab5c (origin/master)
      Description set: origin/master, 7c98dcefea27ba90f5dc64710fdcd9f128f5ab5c
      Finished: SUCCESS
      

      Build #6:

      Started by an SCM change
      [EnvInject] - Loading node environment variables.
      Building remotely on ch06bl09.mgmt.lmc.cz in workspace /srv/jenkins/workspace/NotifyCommitTest3
      Using strategy: Default
      Last Built Revision: Revision 7c98dcefea27ba90f5dc64710fdcd9f128f5ab5c (origin/master)
      Fetching changes from the remote Git repository
      Fetching upstream changes from ssh://git@stash.int.lmc.cz:7999/rec/g2.git
      getCandidateRevisions(false,null,,,null,remoteUrls=[ssh://git@stash.int.lmc.cz:7999/rec/g2.git],buildsByBranchName={origin/master=Build #5 of Revision 7c98dcefea27ba90f5dc64710fdcd9f128f5ab5c (origin/master), origin/bugfix/S14.02/stash-jenkins-test=Build #3 of Revision 6fa2f3f32e94997c84c9a49b36c6346565ce8851 (origin/bugfix/S14.02/stash-jenkins-test)},lastBuild=Build #5 of Revision 7c98dcefea27ba90f5dc64710fdcd9f128f5ab5c (origin/master)]) considering branches to build
      Seen branch in repository origin/bugfix/S14.02/stash-jenkins-test
      Seen branch in repository origin/feature/S14.02/stash-jenkins-test
      Seen branch in repository origin/master
      Seen branch in repository origin/sprint/g2.2
      Seen 4 remote branches
      Starting with all the branches: [Revision 7c98dcefea27ba90f5dc64710fdcd9f128f5ab5c (origin/master), Revision 549bbb10e97a90b1f26db59529ba861797771ccc (origin/feature/S14.02/stash-jenkins-test), Revision 6fa2f3f32e94997c84c9a49b36c6346565ce8851 (origin/bugfix/S14.02/stash-jenkins-test), Revision a8b7d3421db68823b071ca74f269210718929406 (origin/sprint/g2.2)]
      Ignoring Branch origin/sprint/g2.2(AnyObjectId[a8b7d3421db68823b071ca74f269210718929406]) because it doesn't match branch specifier
      Ignoring Revision a8b7d3421db68823b071ca74f269210718929406 () because we don't care about any of the branches that point to it
      After branch filtering: [Revision 7c98dcefea27ba90f5dc64710fdcd9f128f5ab5c (origin/master), Revision 549bbb10e97a90b1f26db59529ba861797771ccc (origin/feature/S14.02/stash-jenkins-test), Revision 6fa2f3f32e94997c84c9a49b36c6346565ce8851 (origin/bugfix/S14.02/stash-jenkins-test)]
      After non-tip filtering: [Revision 7c98dcefea27ba90f5dc64710fdcd9f128f5ab5c (origin/master), Revision 549bbb10e97a90b1f26db59529ba861797771ccc (origin/feature/S14.02/stash-jenkins-test), Revision 6fa2f3f32e94997c84c9a49b36c6346565ce8851 (origin/bugfix/S14.02/stash-jenkins-test)]
      Removing what's already been built: {origin/master=Build #5 of Revision 7c98dcefea27ba90f5dc64710fdcd9f128f5ab5c (origin/master), origin/bugfix/S14.02/stash-jenkins-test=Build #3 of Revision 6fa2f3f32e94997c84c9a49b36c6346565ce8851 (origin/bugfix/S14.02/stash-jenkins-test)}
      After filtering out what's already been built: [Revision 549bbb10e97a90b1f26db59529ba861797771ccc (origin/feature/S14.02/stash-jenkins-test)]
      Checking out Revision 549bbb10e97a90b1f26db59529ba861797771ccc (origin/feature/S14.02/stash-jenkins-test)
      First time build. Skipping changelog.
      Description set: origin/feature/S14.02/stash-jenkins-test, 549bbb10e97a90b1f26db59529ba861797771ccc
      Finished: SUCCESS
      

      Attachments

        Activity

          fk_ fk_ added a comment -

          Why this was closed? The issue is still here, versions are
          Jenkins ver. 1.625.1
          Git Parameter Plug-In 0.4.0
          Git plugin 2.4.2
          Git server plugin 1.6
          GitHub API Plugin 1.72.1
          GitHub plugin 1.17.1
          GitHub Pull Request Builder 1.31.1
          Gitlab Hook Plugin 1.4.1.1
          multiple-scms@0.3

          fk_ fk_ added a comment - Why this was closed? The issue is still here, versions are Jenkins ver. 1.625.1 Git Parameter Plug-In 0.4.0 Git plugin 2.4.2 Git server plugin 1.6 GitHub API Plugin 1.72.1 GitHub plugin 1.17.1 GitHub Pull Request Builder 1.31.1 Gitlab Hook Plugin 1.4.1.1 multiple-scms@0.3
          fk_ fk_ added a comment -

          Actually we found that we had a branch named 'origin/branch' instead of 'branch' and drove jenkins a nuts. After removing 'origin/branch' and purging workspace everything worked fine.

          fk_ fk_ added a comment - Actually we found that we had a branch named 'origin/branch' instead of 'branch' and drove jenkins a nuts. After removing 'origin/branch' and purging workspace everything worked fine.
          markewaite Mark Waite added a comment -

          Won't fix the case where a branch exists named "origin/master" (which can be referenced as origin/origin/master) because that fix seems very likely to break many cases of branch name matching on which users depend.

          markewaite Mark Waite added a comment - Won't fix the case where a branch exists named "origin/master" (which can be referenced as origin/origin/master) because that fix seems very likely to break many cases of branch name matching on which users depend.
          petrjanata petrjanata added a comment -

          I also observed similar behavior. When 'Branch Specifier' was not unique, then checkout actually triggered another build of the same job.

          This was strange, because the job didn't have Poll SCM Build Trigger checked. Actually this job had none of the Build Trigger mechanisms checked and was intended to be scheduled only manually.

          The first build was executed manually with Branch Specifier = branch123 and log contained:

           

           > git rev-parse branch123^{commit} # timeout=10
           > git rev-parse refs/remotes/origin/branch123^{commit} # timeout=10
          Multiple candidate revisions
          Scheduling another build to catch up with My_Build_Job_Name
          

          At that point a new unwanted build of this job was scheduled and waited in the Build Queue. When it started, the log contained:

           

          Started by an SCM change
          Building on master

          The initial problem was non-unique Branch Specifier. I will fix it by using the longer remote ref refs/remotes/origin/branch123.

          markewaite Could you consider changing the plugin to fail instead of triggering a new build in case non-unique revision is required to be checked out? At least in case when job does not allow Poll SCM Build Trigger.


          What was the job for and how this issue happened?

          The job uses Jenkins job SCM Git to checkout a branch (say branch123) with Clean before checkout. Then in Execute shell build step it modifies some files in the checkout (pom.xmls), commits, tags (as tag123-rc1) and pushes. The local branch123 HEAD points to the same commit as tag123-rc1. So far so good.

          Then developers push more changes into branch123 and we want to release as tag123-rc2. So we run our job again. Git-plugin does cleanup on the repository in the job workspace, but this leaves the local branch123 intact, so it still points to the same revision as tag123-rc1. (so other viable solution would be to wipe workspace between builds)

          Plugin then fetches refs from remote and refs/remotes/origin/branch123 now points to the new commits made by developers. Git-plugin compares revision of both references that contain substring branch123. Since the remote branch moved, both refs now point to different revisions. Git-plugin reacts to this with 'Multiple candidate revisions' message and triggers a new build.

          In case both refs point to the same revision (no changes were made on the branch between two builds), then Git-plugin checks out the single revision and no build is triggered.

           > git config remote.origin.url ssh://XXX.git # timeout=10
          Cleaning workspace
           > git rev-parse --verify HEAD # timeout=10
          Resetting working tree
           > git reset --hard # timeout=10
           > git clean -fdx # timeout=10
           > git submodule foreach --recursive git reset --hard # timeout=10
           > git submodule foreach --recursive git clean -fdx # timeout=10
          Fetching upstream changes from ssh://XXX.git
           > git --version # timeout=10
          using GIT_SSH to set credentials XXX
           > git fetch --tags --progress ssh://XXX.git +refs/heads/*:refs/remotes/origin/*
           > git rev-parse branch123^{commit} # timeout=10
           > git rev-parse refs/remotes/origin/branch123^{commit} # timeout=10
          Multiple candidate revisions
          Scheduling another build to catch up with My_Build_Job_Name

           

          petrjanata petrjanata added a comment - I also observed similar behavior. When 'Branch Specifier' was not unique, then checkout actually triggered another build of the same job. This was strange, because the job didn't have Poll SCM Build Trigger checked. Actually this job had none of the Build Trigger mechanisms checked and was intended to be scheduled only manually. The first build was executed manually with Branch Specifier = branch123 and log contained:   > git rev-parse branch123^{commit} # timeout=10 > git rev-parse refs/remotes/origin/branch123^{commit} # timeout=10 Multiple candidate revisions Scheduling another build to catch up with My_Build_Job_Name At that point a new unwanted build of this job was scheduled and waited in the Build Queue. When it started, the log contained:   Started by an SCM change Building on master The initial problem was non-unique Branch Specifier. I will fix it by using the longer remote ref refs/remotes/origin/branch123. markewaite Could you consider changing the plugin to fail instead of triggering a new build in case non-unique revision is required to be checked out? At least in case when job does not allow Poll SCM Build Trigger. What was the job for and how this issue happened? The job uses Jenkins job SCM Git to checkout a branch (say branch123) with Clean before checkout. Then in Execute shell build step it modifies some files in the checkout (pom.xmls), commits, tags (as tag123-rc1) and pushes. The local branch123 HEAD points to the same commit as tag123-rc1. So far so good. Then developers push more changes into branch123 and we want to release as tag123-rc2. So we run our job again. Git-plugin does cleanup on the repository in the job workspace, but this leaves the local branch123 intact, so it still points to the same revision as tag123-rc1. (so other viable solution would be to wipe workspace between builds) Plugin then fetches refs from remote and refs/remotes/origin/branch123 now points to the new commits made by developers. Git-plugin compares revision of both references that contain substring branch123. Since the remote branch moved, both refs now point to different revisions. Git-plugin reacts to this with 'Multiple candidate revisions' message and triggers a new build. In case both refs point to the same revision (no changes were made on the branch between two builds), then Git-plugin checks out the single revision and no build is triggered. > git config remote.origin.url ssh: //XXX.git # timeout=10 Cleaning workspace > git rev-parse --verify HEAD # timeout=10 Resetting working tree > git reset --hard # timeout=10 > git clean -fdx # timeout=10 > git submodule foreach --recursive git reset --hard # timeout=10 > git submodule foreach --recursive git clean -fdx # timeout=10 Fetching upstream changes from ssh: //XXX.git > git --version # timeout=10 using GIT_SSH to set credentials XXX > git fetch --tags --progress ssh: //XXX.git +refs/heads/*:refs/remotes/origin/* > git rev-parse branch123^{commit} # timeout=10 > git rev-parse refs/remotes/origin/branch123^{commit} # timeout=10 Multiple candidate revisions Scheduling another build to catch up with My_Build_Job_Name  
          markewaite Mark Waite added a comment - - edited

          petrjanata you asked:

          Could you consider changing the plugin to fail instead of triggering a new build in case non-unique revision is required to be checked out? At least in case when job does not allow Poll SCM Build Trigger.

          No, I'm not willing to change the plugin to fail instead of triggering a new build in case a non-unique revision is required to be checked out. I believe that will break more use cases than it fixes and will introduce an incompatibility which will cause problems for many users.

          markewaite Mark Waite added a comment - - edited petrjanata you asked: Could you consider changing the plugin to fail instead of triggering a new build in case non-unique revision is required to be checked out? At least in case when job does not allow Poll SCM Build Trigger. No, I'm not willing to change the plugin to fail instead of triggering a new build in case a non-unique revision is required to be checked out. I believe that will break more use cases than it fixes and will introduce an incompatibility which will cause problems for many users.

          People

            markewaite Mark Waite
            minarikv Vojta Minarik
            Votes:
            8 Vote for this issue
            Watchers:
            22 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: