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

Unexpected job deletion with "Exclude branches that are also filed as PRs" when opening a PR

      Given:

      Jenkins: Branch scanning with "Discover Branches Strategy" set to "Exclude branches that are also filed as PRs"

      Bitbucket: Automatic merging enabled

      When:

      Merging changes from feature/X into release/Y, where automatic merge from release/Y into master fails.

      Then:

      Bitbucket creates new PR-Z for merging release/Y into master. Jenkins deletes old release/Y job, and creates new PR-Z job. Upon PR closure, PR job is deleted and release/Y job re-created starting from BUILD_NUMBER=1

       

      The underlying issue is the ability to unintentionally delete branch jobs by simply opening a PR. As another example, it is also possible to delete master job by simply requesting master branch to be merged anywhere else.

      I don't see any nice way around this, other than introducing another type of filter that would specify "permanent/sticky" jobs - ones that will never be deleted, only disabled if no longer matched by the normal branch filter. Any thoughts?

          [JENKINS-52406] Unexpected job deletion with "Exclude branches that are also filed as PRs" when opening a PR

          Anders Hammar added a comment -

          We've run into this as well (see JENKINS-65275). However, I don't think that the current behavior is correct as the discard old items text says:

          Jobs for removed SCM heads (i.e. deleted branches) can be removed immediately or kept based on a desired retention strategy.

          But as the branch still exists, it shouldn't be removed.

          Anders Hammar added a comment - We've run into this as well (see JENKINS-65275 ). However, I don't think that the current behavior is correct as the discard old items text says: Jobs for removed SCM heads (i.e. deleted branches) can be removed immediately or kept based on a desired retention strategy. But as the branch still exists, it shouldn't be removed.

          Anders Hammar added a comment -

          I'm tracing what happens and I'm trying to understand all the involved parts/plugins. To me it looks like the problem is that bitbucket-branch-source-plugin adds the branches as orphaned. That makes the DefaultOrphanedItemStrategy then removed them.
          There should be some other way of disabling those branch jobs, without marking them as orphaned.

          Anders Hammar added a comment - I'm tracing what happens and I'm trying to understand all the involved parts/plugins. To me it looks like the problem is that bitbucket-branch-source-plugin adds the branches as orphaned. That makes the DefaultOrphanedItemStrategy then removed them. There should be some other way of disabling those branch jobs, without marking them as orphaned.

          Anders Hammar added a comment -

          I tested with github-branch-source-plugin and it's the same behavior with that plugin and a github.org repo. So I added it to components.

          Anders Hammar added a comment - I tested with github-branch-source-plugin and it's the same behavior with that plugin and a github.org repo. So I added it to components.

            Unassigned Unassigned
            sbgerdp Gert Palok
            Votes:
            2 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated: