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

Prune stale branches prevents git plugin change history display

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • git-plugin
    • None
    • git plugin 2.3.6 pre-release (pre-release for git 2.4.0)
      git client plugin 1.18.0 pre-release

      A git SCM based job will stop showing changes (both "Recent Changes" and "Changes") if "Prune stale remote-tracking branches" is enabled. It will resume showing changes if the "Prune stake remote-tracking branches is removed from the job definition.

      It appears that a new method "purgeStaleBranches" was added to the git plugin in March 2015 . It is purging a branch named "refs/remotes/origin/master" even though that is the only branch defined in the job.

      To duplicate the problem:

      1. Start Jenkins
      2. Install pre-release git client plugin
      3. Install pre-release git plugin
      4. Configure a new job with Git SCM as source control
      5. Configure the job to poll SCM frequently (once a minute)
      6. Run the job once, confirm no history is shown
      7. Commit a change to the repository that job is tracking
      8. Wait for polling to detect the change, confirm history is shown
      9. Reconfigure job to add "Prune stale remote-tracking branches"
      10. Commit a change to the repository that job is tracking
      11. Wait for polling to detect the change, confirm history is shown
      12. Commit another change to the repository that job is tracking
      13. Wait for polling to detect the change, confirm history is NOT shown

      Once history is not being shown, it will continue to not be shown, even though the polling log and the build status page shows that the job was started by an SCM change.

      If the "Prune stale remote-tracking branches" setting is removed, then two builds later the job will begin showing history again.

        1. Selection_046.png
          Selection_046.png
          22 kB
        2. Selection_045.png
          Selection_045.png
          15 kB
        3. Selection_044.png
          Selection_044.png
          48 kB
        4. Selection_043.png
          Selection_043.png
          86 kB
        5. Selection_042.png
          Selection_042.png
          45 kB

          [JENKINS-29482] Prune stale branches prevents git plugin change history display

          Mark Waite created issue -
          Mark Waite made changes -
          Description Original: A git SCM based job will stop showing changes (both "Recent Changes" and "Changes") if "Prune stale remote-tracking branches" is enabled. It will resume showing changes if the "Prune stake remote-tracking branches is removed from the job definition.

          It appears that a new method "purgeStaleBranches" was added to the git plugin in commit 163e60fccd5a08199efd7d85b0b351c6e950c2f7 . It is purging a branch named "refs/remotes/origin/master" even though that is the only branch defined in the job.

          To duplicate the problem:
          # Start Jenkins
          # Install pre-release git client plugin
          # Install pre-release git plugin
          # Configure a new job with Git SCM as source control
          # Configure the job to poll SCM frequently (once a minute)
          # Run the job once
          # Commit a change to the repository that job is tracking
          # Wait for change polling to detect the change
          # Confirm that the bug exists - no change is listed, even though the change was started by an SCM change
          New: A git SCM based job will stop showing changes (both "Recent Changes" and "Changes") if "Prune stale remote-tracking branches" is enabled. It will resume showing changes if the "Prune stake remote-tracking branches is removed from the job definition.

          It appears that a new method "purgeStaleBranches" was added to the [git plugin in March 2015|https://github.com/jenkinsci/git-plugin/commit/163e60fccd5a08199efd7d85b0b351c6e950c2f7] . It is purging a branch named "refs/remotes/origin/master" even though that is the only branch defined in the job.

          To duplicate the problem:
          # Start Jenkins
          # Install pre-release git client plugin
          # Install pre-release git plugin
          # Configure a new job with Git SCM as source control
          # Configure the job to poll SCM frequently (once a minute)
          # Run the job once
          # Commit a change to the repository that job is tracking
          # Wait for change polling to detect the change
          # Confirm that the bug exists - no change is listed, even though the change was started by an SCM change
          Mark Waite made changes -
          Description Original: A git SCM based job will stop showing changes (both "Recent Changes" and "Changes") if "Prune stale remote-tracking branches" is enabled. It will resume showing changes if the "Prune stake remote-tracking branches is removed from the job definition.

          It appears that a new method "purgeStaleBranches" was added to the [git plugin in March 2015|https://github.com/jenkinsci/git-plugin/commit/163e60fccd5a08199efd7d85b0b351c6e950c2f7] . It is purging a branch named "refs/remotes/origin/master" even though that is the only branch defined in the job.

          To duplicate the problem:
          # Start Jenkins
          # Install pre-release git client plugin
          # Install pre-release git plugin
          # Configure a new job with Git SCM as source control
          # Configure the job to poll SCM frequently (once a minute)
          # Run the job once
          # Commit a change to the repository that job is tracking
          # Wait for change polling to detect the change
          # Confirm that the bug exists - no change is listed, even though the change was started by an SCM change
          New: A git SCM based job will stop showing changes (both "Recent Changes" and "Changes") if "Prune stale remote-tracking branches" is enabled. It will resume showing changes if the "Prune stake remote-tracking branches is removed from the job definition.

          It appears that a new method "purgeStaleBranches" was added to the [git plugin in March 2015|https://github.com/jenkinsci/git-plugin/commit/163e60fccd5a08199efd7d85b0b351c6e950c2f7] . It is purging a branch named "refs/remotes/origin/master" even though that is the only branch defined in the job.

          To duplicate the problem:
          # Start Jenkins
          # Install pre-release git client plugin
          # Install pre-release git plugin
          # Configure a new job with Git SCM as source control
          # Configure the job to poll SCM frequently (once a minute)
          # Run the job once, confirm no history is shown
          # Commit a change to the repository that job is tracking
          # Wait for polling to detect the change, confirm history is shown
          # Reconfigure job to add "Prune stale remote-tracking branches"
          # Commit a change to the repository that job is tracking
          # Wait for polling to detect the change, confirm history is shown
          # Commit another change to the repository that job is tracking
          # Wait for polling to detect the change, confirm history is *NOT* shown

          Once history is not being shown, it will continue to not be shown, even though the polling log and the build status page shows that the job was started by an SCM change.

          If the "Prune stale remote-tracking branches" setting is removed, then two builds later the job will begin showing history again.

          Code changed in jenkins
          User: Mark Waite
          Path:
          src/main/java/hudson/plugins/git/extensions/impl/PruneStaleBranch.java
          src/main/java/hudson/plugins/git/util/BuildData.java
          http://jenkins-ci.org/commit/git-plugin/be1890377a4623be9483e6b70df22cd8da2f7616
          Log:
          [Fix JENKINS-29482] Don't hide build history when prune stale branches is on

          Reverts "prune deleted branches from BuildData to avoid growing memory consumption"

          This reverts the bulk of commit 163e60fccd5a08199efd7d85b0b351c6e950c2f7.
          The two test cases which were added are still retained, though it is odd
          that they are unaffected by reverting the change to the production code.
          As far as I can tell, the BuildData.purgeStaleBranches method was not
          called by any test, even though it seems it should have been called.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Mark Waite Path: src/main/java/hudson/plugins/git/extensions/impl/PruneStaleBranch.java src/main/java/hudson/plugins/git/util/BuildData.java http://jenkins-ci.org/commit/git-plugin/be1890377a4623be9483e6b70df22cd8da2f7616 Log: [Fix JENKINS-29482] Don't hide build history when prune stale branches is on Reverts "prune deleted branches from BuildData to avoid growing memory consumption" This reverts the bulk of commit 163e60fccd5a08199efd7d85b0b351c6e950c2f7. The two test cases which were added are still retained, though it is odd that they are unaffected by reverting the change to the production code. As far as I can tell, the BuildData.purgeStaleBranches method was not called by any test, even though it seems it should have been called.

          Mark Waite added a comment -

          Fix included in git plugin 2.4.0 released 18 July 2015

          Mark Waite added a comment - Fix included in git plugin 2.4.0 released 18 July 2015
          Mark Waite made changes -
          Resolution New: Fixed [ 1 ]
          Status Original: Open [ 1 ] New: Resolved [ 5 ]
          Mark Waite made changes -
          Status Original: Resolved [ 5 ] New: Closed [ 6 ]

          Code changed in jenkins
          User: Nicolas De Loof
          Path:
          src/main/java/hudson/plugins/git/extensions/impl/PruneStaleBranch.java
          src/main/java/hudson/plugins/git/util/BuildData.java
          http://jenkins-ci.org/commit/git-plugin/c1872d038cc2f584bafbc375744deb54a1dbe316
          Log:
          [Fix JENKINS-29482] remove branches in BuildData history which doesn’t exist on remote repo (anymore)

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Nicolas De Loof Path: src/main/java/hudson/plugins/git/extensions/impl/PruneStaleBranch.java src/main/java/hudson/plugins/git/util/BuildData.java http://jenkins-ci.org/commit/git-plugin/c1872d038cc2f584bafbc375744deb54a1dbe316 Log: [Fix JENKINS-29482] remove branches in BuildData history which doesn’t exist on remote repo (anymore)

          Broken again in git plugin 2.4.1, git client plugin 1.19.1.

          The reproduction steps are the same as in the original bug description.

          Apparently, the GIT_PREVIOUS_COMMIT is always empty after the first build with eabled pruning and hence no change log is computed further on.

          Following are the logs of three consecutive builds. The pruning feature was enabled after the first build.

          Commit without pruning
           > git.exe rev-parse --is-inside-work-tree # timeout=10
          Fetching changes from the remote Git repository
           > git.exe config remote.origin.url http://localhost:9090/gitblit/r/sandbox/playground.git # timeout=10
          Fetching upstream changes from http://localhost:9090/gitblit/r/sandbox/playground.git
           > git.exe --version # timeout=10
           > git.exe -c core.askpass=true fetch --tags --progress http://localhost:9090/gitblit/r/sandbox/playground.git +refs/heads/*:refs/remotes/origin/*
           > git.exe rev-parse "refs/remotes/origin/master^{commit}" # timeout=10
           > git.exe rev-parse "refs/remotes/origin/origin/master^{commit}" # timeout=10
          Checking out Revision 8702e88ffe677c945897e3abfb365427ec7f72ce (refs/remotes/origin/master)
           > git.exe config core.sparsecheckout # timeout=10
           > git.exe checkout -f 8702e88ffe677c945897e3abfb365427ec7f72ce
           > git.exe rev-list 74d735418e3965032dd68103d02d5041589dd49b # timeout=10
          
          First commit with pruning
           > git.exe rev-parse --is-inside-work-tree # timeout=10
          Fetching changes from the remote Git repository
           > git.exe config remote.origin.url http://localhost:9090/gitblit/r/sandbox/playground.git # timeout=10
          Pruning obsolete local branches
          Fetching upstream changes from http://localhost:9090/gitblit/r/sandbox/playground.git
           > git.exe --version # timeout=10
           > git.exe -c core.askpass=true fetch --tags --progress http://localhost:9090/gitblit/r/sandbox/playground.git +refs/heads/*:refs/remotes/origin/* --prune
           > git.exe rev-parse "refs/remotes/origin/master^{commit}" # timeout=10
           > git.exe rev-parse "refs/remotes/origin/origin/master^{commit}" # timeout=10
          Checking out Revision f1f6a7a48503f17ce61c72d62e8d3c89a150790d (refs/remotes/origin/master)
           > git.exe config core.sparsecheckout # timeout=10
           > git.exe checkout -f f1f6a7a48503f17ce61c72d62e8d3c89a150790d
           > git.exe rev-list 8702e88ffe677c945897e3abfb365427ec7f72ce # timeout=10
           > git.exe branch -a # timeout=10
           > git.exe rev-parse "remotes/origin/master^{commit}" # timeout=10
          
          Second commit with pruning
            > git.exe rev-parse --is-inside-work-tree # timeout=10
          Fetching changes from the remote Git repository
           > git.exe config remote.origin.url http://localhost:9090/gitblit/r/sandbox/playground.git # timeout=10
          Pruning obsolete local branches
          Fetching upstream changes from http://localhost:9090/gitblit/r/sandbox/playground.git
           > git.exe --version # timeout=10
           > git.exe -c core.askpass=true fetch --tags --progress http://localhost:9090/gitblit/r/sandbox/playground.git +refs/heads/*:refs/remotes/origin/* --prune
           > git.exe rev-parse "refs/remotes/origin/master^{commit}" # timeout=10
           > git.exe rev-parse "refs/remotes/origin/origin/master^{commit}" # timeout=10
          Checking out Revision 61acc139dcbd11c40f8eb31d1c9be88cb02b2de8 (refs/remotes/origin/master)
           > git.exe config core.sparsecheckout # timeout=10
           > git.exe checkout -f 61acc139dcbd11c40f8eb31d1c9be88cb02b2de8
          First time build. Skipping changelog.
           > git.exe branch -a # timeout=10
           > git.exe rev-parse "remotes/origin/master^{commit}" # timeout=10
          

          Ramin Baradari added a comment - Broken again in git plugin 2.4.1, git client plugin 1.19.1. The reproduction steps are the same as in the original bug description. Apparently, the GIT_PREVIOUS_COMMIT is always empty after the first build with eabled pruning and hence no change log is computed further on. Following are the logs of three consecutive builds. The pruning feature was enabled after the first build. Commit without pruning > git.exe rev-parse --is-inside-work-tree # timeout=10 Fetching changes from the remote Git repository > git.exe config remote.origin.url http: //localhost:9090/gitblit/r/sandbox/playground.git # timeout=10 Fetching upstream changes from http: //localhost:9090/gitblit/r/sandbox/playground.git > git.exe --version # timeout=10 > git.exe -c core.askpass= true fetch --tags --progress http: //localhost:9090/gitblit/r/sandbox/playground.git +refs/heads/*:refs/remotes/origin/* > git.exe rev-parse "refs/remotes/origin/master^{commit}" # timeout=10 > git.exe rev-parse "refs/remotes/origin/origin/master^{commit}" # timeout=10 Checking out Revision 8702e88ffe677c945897e3abfb365427ec7f72ce (refs/remotes/origin/master) > git.exe config core.sparsecheckout # timeout=10 > git.exe checkout -f 8702e88ffe677c945897e3abfb365427ec7f72ce > git.exe rev-list 74d735418e3965032dd68103d02d5041589dd49b # timeout=10 First commit with pruning > git.exe rev-parse --is-inside-work-tree # timeout=10 Fetching changes from the remote Git repository > git.exe config remote.origin.url http: //localhost:9090/gitblit/r/sandbox/playground.git # timeout=10 Pruning obsolete local branches Fetching upstream changes from http: //localhost:9090/gitblit/r/sandbox/playground.git > git.exe --version # timeout=10 > git.exe -c core.askpass= true fetch --tags --progress http: //localhost:9090/gitblit/r/sandbox/playground.git +refs/heads/*:refs/remotes/origin/* --prune > git.exe rev-parse "refs/remotes/origin/master^{commit}" # timeout=10 > git.exe rev-parse "refs/remotes/origin/origin/master^{commit}" # timeout=10 Checking out Revision f1f6a7a48503f17ce61c72d62e8d3c89a150790d (refs/remotes/origin/master) > git.exe config core.sparsecheckout # timeout=10 > git.exe checkout -f f1f6a7a48503f17ce61c72d62e8d3c89a150790d > git.exe rev-list 8702e88ffe677c945897e3abfb365427ec7f72ce # timeout=10 > git.exe branch -a # timeout=10 > git.exe rev-parse "remotes/origin/master^{commit}" # timeout=10 Second commit with pruning > git.exe rev-parse --is-inside-work-tree # timeout=10 Fetching changes from the remote Git repository > git.exe config remote.origin.url http: //localhost:9090/gitblit/r/sandbox/playground.git # timeout=10 Pruning obsolete local branches Fetching upstream changes from http: //localhost:9090/gitblit/r/sandbox/playground.git > git.exe --version # timeout=10 > git.exe -c core.askpass= true fetch --tags --progress http: //localhost:9090/gitblit/r/sandbox/playground.git +refs/heads/*:refs/remotes/origin/* --prune > git.exe rev-parse "refs/remotes/origin/master^{commit}" # timeout=10 > git.exe rev-parse "refs/remotes/origin/origin/master^{commit}" # timeout=10 Checking out Revision 61acc139dcbd11c40f8eb31d1c9be88cb02b2de8 (refs/remotes/origin/master) > git.exe config core.sparsecheckout # timeout=10 > git.exe checkout -f 61acc139dcbd11c40f8eb31d1c9be88cb02b2de8 First time build. Skipping changelog. > git.exe branch -a # timeout=10 > git.exe rev-parse "remotes/origin/master^{commit}" # timeout=10
          Ramin Baradari made changes -
          Resolution Original: Fixed [ 1 ]
          Status Original: Closed [ 6 ] New: Reopened [ 4 ]

            markewaite Mark Waite
            markewaite Mark Waite
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: