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

Multibranch Pipeline does not prune/track remote branches with git 1.7.1

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      Today i was wondering why a branch that was deleted on the remote repository does not get marked as removed in the Pipeline Multibranch Projekt.

      So I did a couple of "Scan Multibranch Pipeline Now" and had a closer look at the log, but while the statements seemed ok in the first place, the branches are still all listed and even though a prune option is on the fetch they did not get removed.

       > /usr/bin/git rev-parse --is-inside-work-tree # timeout=10
      Setting origin to gitserver:/data/git/Repository.git
       > /usr/bin/git config remote.origin.url gitserver:/data/git/Repository.git # timeout=10
      Fetching origin...
      Fetching upstream changes from origin
       > /usr/bin/git --version # timeout=10
      using GIT_SSH to set credentials Jenkins private Key zur Authentifizierung auf gitserver
       > /usr/bin/git fetch --tags --progress origin +refs/heads/*:refs/remotes/origin/*
      using GIT_SSH to set credentials Jenkins private Key zur Authentifizierung auf gitserver
       > /usr/bin/git ls-remote gitserver:/data/git/Repository.git # timeout=10
       > /usr/bin/git rev-parse --is-inside-work-tree # timeout=10
      Setting origin to gitserver:/data/git/Repository.git
       > /usr/bin/git config remote.origin.url gitserver:/data/git/Repository.git # timeout=10
      Fetching & pruning origin...
      Fetching upstream changes from origin
       > /usr/bin/git --version # timeout=10
      using GIT_SSH to set credentials Jenkins private Key zur Authentifizierung auf gitserver
       > /usr/bin/git fetch --tags --progress origin +refs/heads/*:refs/remotes/origin/* --prune
      Getting remote branches...
      Seen branch in repository origin/bugfix/JIRA-6365
      Seen branch in repository origin/development
      Seen branch in repository origin/release/14.1
      ...

      so i was looking into the <JENKINS_HOME>/cache directory and fired a couple of git commands manually:

      git prune
      git fetch --prune
      git remote prune origin
      

      but nothing happened to the refs/remotes/origin/bugfix... (that should haved been removed)
      after more investigation I stumbled upon the following command and compared the output to my local copy and the surprise was that all branches in the jenkins cache does not seem to be tracked:

      # in the Jenkins cache (used for the multi branch indexing)
      git remote show origin
      * remote origin
        Fetch URL: gitserver:/data/git/Repository.git
        Push  URL: gitserver:/data/git/Repository.git
        HEAD branch: development
      
      # locally cloned repository
       git remote show origin
      * remote origin
        Fetch URL: gitserver:/data/git/Repository.git
        Push  URL: gitserver:/data/git/Repository.git
        HEAD branch: development
        Remote branches:
          bugfix/JIRA-6365 tracked
          development      tracked
          release/14.1     tracked
        Local branches configured for 'git pull':
      ...
        Local refs configured for 'git push':
      ...
      

      The only difference I could find was that in the .git/config

      [remote "origin"]
              url = gitserver:/data/git/Repository.git
              fetch = +refs/heads/*:refs/remotes/origin/*
      

      the fetch line was missing. After I added that in a local copy and made a git fetch --prune the stale branches got removed.

      git fetch --prune
      From gitserver:/data/git/Repository.git
       - [deleted]           (none)     -> origin/bugfix/JIRA-6365
      

      I also replayed the commands from the Multibranch Scan Log with a local git (git version 2.13.0.windows.1) and had the same problems - the remote references where fetched but not tracked.

      I hope I did not miss a thing here and you can fix this.

      Update: Jenkins is using the command line git in version 1.7.1

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            dageissl Daniel Geißler
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: