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

Multibranch pipeline project jobs are not deleted when branches are deleted

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Critical
    • Resolution: Fixed
    • git-plugin
    • None
    • git-plugin compiled from master.
      This bug does not exist in git-plugin 2.5.3

    Description

      Problem

      If you compile git-plugin from the source, and set 'Discard old items' in the multibranch pipeline, deleted branches on the SCM are not deleted from the job list. If you install the 2.5.3 version of this plugin and restart Jenkins, these branches are deleted.

      How to reproduce it

      Configure a Jenkins installation

      1. Download a fresh Jenkins (2.7.2), rename your current home
      2. Start it: java -jar jenkins.war
      3. Choose the default packages option during the first boot
      4. Clone git-plugin repository, compile it (mvn.cmd '-Dmaven.test.skip=true' clean install hpi:hpi)
      5. Import your git-plugin (the one you compiled) in Jenkins (advanced tab)
      6. Restart Jenkins

      See the error

      1. Create a test git repository with a Jenkinsfile on many branches
      2. Add a new multibranch pipeline, select "Discard old items"
      3. Save, check that your branches appear in the list
      4. Delete a branch from your repository. git push origin :features/a-random-branch
      5. Run a branch indexing
      6. See that your branch was not deleted

      Check that 2.5.3 is working

      1. Restore the git-plugin in its original version, 2.5.3
      2. Restart Jenkins
      3. Rerun branch indexing, see that your branch has disappeared !

      Investigations

      I didn't have the time to run a Jenkins instance in debug, or to read the commits yet. So I've no idea why this bug happens. I'll update this section later if I've time.

      Attachments

        Activity

          assafl Leibo added a comment - - edited

          Hi,

          Added the JGit as explained and got authentication error... after some issues searching I created a new user based on our SSH private key authentication and it seems working!!!

          So we're good I hope.

          Thanks a lot for the fast response

          assafl Leibo added a comment - - edited Hi, Added the JGit as explained and got authentication error... after some issues searching I created a new user based on our SSH private key authentication and it seems working!!! So we're good I hope. Thanks a lot for the fast response
          markewaite Mark Waite added a comment -

          I'm glad it is working for you, though I'm skeptical that the issue is fully resolved. I don't yet understand the conditions which caused you (and me) to see the issue, while superboum and I to not see the issue. I realize it is strange that I've both seen the problem, and not seen the problem, but that just means I don't really understand the circumstances which show the bug.

          markewaite Mark Waite added a comment - I'm glad it is working for you, though I'm skeptical that the issue is fully resolved. I don't yet understand the conditions which caused you (and me) to see the issue, while superboum and I to not see the issue. I realize it is strange that I've both seen the problem, and not seen the problem, but that just means I don't really understand the circumstances which show the bug.
          gelefisk Øystein Kjærnet added a comment - - edited

          I experience exactly the same as Leibo - old jobs from deleted branches not being deleted, even though I've selected "Discard old items" in the build config - choosing JGit as suggested by Mark fixed this. Jenkins version 2.20, Git plugin 3.0.0, Git client plugin 2.0.0, Build Pipeline 1.5.4, Pipeline: Multibranch 2.8, git version on system: 1.7.1. I'd be glad to help debugging this in any way...

          gelefisk Øystein Kjærnet added a comment - - edited I experience exactly the same as Leibo - old jobs from deleted branches not being deleted, even though I've selected "Discard old items" in the build config - choosing JGit as suggested by Mark fixed this. Jenkins version 2.20, Git plugin 3.0.0, Git client plugin 2.0.0, Build Pipeline 1.5.4, Pipeline: Multibranch 2.8, git version on system: 1.7.1. I'd be glad to help debugging this in any way...
          markewaite Mark Waite added a comment - - edited

          gelefisk can you confirm that in your environment git plugin 2.5.3 does not show the problem, while git plugin 2.6.0 and git plugin 3.0.0 show the problem?

          Can you also explore further to see if you can detect the set of steps which would show the problem on a fresh installation?

          If that works, then could you explore placing that fresh set of steps into a job on a docker instance (preferably as a pull request to the bugs folder of my lts-with-plugins branch)?

          markewaite Mark Waite added a comment - - edited gelefisk can you confirm that in your environment git plugin 2.5.3 does not show the problem, while git plugin 2.6.0 and git plugin 3.0.0 show the problem? Can you also explore further to see if you can detect the set of steps which would show the problem on a fresh installation? If that works, then could you explore placing that fresh set of steps into a job on a docker instance (preferably as a pull request to the bugs folder of my lts-with-plugins branch )?
          marius_balteanu Marius Balteanu added a comment - - edited

          I've the same issue and downgrading the Git plugin to 2.5.3 didn't solve the issue. I'll try the jgit workaround.

          • git client plugin 2.1.0
          • git plugin 2.5.3 / 3.0.0
          • pipeline multibranch 2.9.2
          • git version on the server 2.9.2

          Please ignore my above comment because my problem was from the job configuration.

          marius_balteanu Marius Balteanu added a comment - - edited I've the same issue and downgrading the Git plugin to 2.5.3 didn't solve the issue. I'll try the jgit workaround. git client plugin 2.1.0 git plugin 2.5.3 / 3.0.0 pipeline multibranch 2.9.2 git version on the server 2.9.2 Please ignore my above comment because my problem was from the job configuration.

          People

            markewaite Mark Waite
            superboum Quentin Dufour
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: