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

Jobs for branches with PRs are removed although they still exist

      For a multibranch pipeline job, we see that branches in the git repo where there is a PR created will be removed when "discard old items" is enabled. This is surprising as the text states:

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

      Also, probably related, we have "Exclude branches that are also files as PRs" selected as Discover branches strategy.

      So for a scenario where a PR has been created from branch A, I guess what is happening is that the discover strategy creates a new job for the PR and disables the job for branch A. Then it looks like the discard logic removes the job for branch A. EVen though branch A very much still exists and that is not correct according to the text. Only jobs for branches that have been deleted should be discarded/removed.

      I don't know if the problem is in bitbucket-branch-source-plugin or in branch-api.

          [JENKINS-65275] Jobs for branches with PRs are removed although they still exist

          Anders Hammar added a comment -

          This behavior is a problem when GitFlow or similar is used as jobs for branches like 'candidate' are removed when changes are "moved" to the next branch (via a PR).

          Anders Hammar added a comment - This behavior is a problem when GitFlow or similar is used as jobs for branches like 'candidate' are removed when changes are "moved" to the next branch (via a PR).

          Anders Hammar added a comment -

          This is a duplicate of JENKINS-52406.

          Anders Hammar added a comment - This is a duplicate of JENKINS-52406 .

          Nikolas Falco added a comment -

          The job is removed because you chose "Exclude branches that are also filed like PR" in the discovery strategy. In this case all HEADs related to branches (refs/heads/branchXYZ) for which a PR exists, are discarded. This means that the scm-api plugin considers the job to be deleted and removes it (not disables) following the configured policies. This is how the option works, normally you never want the feature branch to produce duplicate builds (like branch job and pr job).

          If you don't want the branches to be deleted, choose the "All branches" option and use a "Filter name" to exclude the "feature/*" branches so that you can keep master, release, whatever branch you want alive even if it is subject to PR. You may get duplicated builds depending on where the commit is pushed, for example pushing to release branch will produce a build on release job and a build on PR jobs where release branch is the source branch

          Jobs for removed SCM heads (i.e. deleted branches)

          Just to clarify "removing SCM head" does not literally mean deleting a branch, it was an example but it means that there is no longer a branch representation (a pointer) for which a jenkins job exists (typical use case of the named filter to configured to discard/ignore some HEAD names)

          Nikolas Falco added a comment - The job is removed because you chose "Exclude branches that are also filed like PR" in the discovery strategy. In this case all HEADs related to branches (refs/heads/branchXYZ) for which a PR exists, are discarded. This means that the scm-api plugin considers the job to be deleted and removes it ( not disables ) following the configured policies. This is how the option works, normally you never want the feature branch to produce duplicate builds (like branch job and pr job). If you don't want the branches to be deleted, choose the "All branches" option and use a "Filter name" to exclude the "feature/*" branches so that you can keep master, release, whatever branch you want alive even if it is subject to PR. You may get duplicated builds depending on where the commit is pushed, for example pushing to release branch will produce a build on release job and a build on PR jobs where release branch is the source branch Jobs for removed SCM heads (i.e. deleted branches) Just to clarify "removing SCM head" does not literally mean deleting a branch, it was an example but it means that there is no longer a branch representation (a pointer) for which a jenkins job exists (typical use case of the named filter to configured to discard/ignore some HEAD names)

            Unassigned Unassigned
            ahammar Anders Hammar
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: