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

Multibranch Pipeline - Orphaned Item Strategy not removing builds for closed PR's until next scan

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • None

      I have a Bitbucket multibranch pipeline set to discover only PR's. The orphaned item strategy is set to discard old items with both options 'Days to keep old items' and 'Max # of old items to keep' being empty. The config.xml for my top level job contains this

       <orphanedItemStrategy class="com.cloudbees.hudson.plugins.folder.computed.DefaultOrphanedItemStrategy" plugin="cloudbees-folder@6.1037.v4cb_8573b_72a_a_"> 
          <pruneDeadBranches>true</pruneDeadBranches> 
          <daysToKeep>-1</daysToKeep> 
          <numToKeep>-1</numToKeep> 
          <abortBuilds>false</abortBuilds> 
        </orphanedItemStrategy>

      With these settings build jobs for closed PR's are never deleted. Jenkins does notice that a PR was closed because the build jobs is stricken through in this case, but not removed. The event log shows 'PREvent REMOVED' is received.

       

      [Wed Aug 06 17:23:26 UTC 2025] Received com.cloudbees.jenkins.plugins.bitbucket.hooks.PREvent CREATED event from 104.192.140.240 ⇒ https://jenknis.mydomain.com:8080/bitbucket-scmsource-hook/notify with timestamp Wed Aug 06 17:23:21 UTC 2025
      Connecting to https://bitbucket.org using xh2XVc8rjZurKMzFwS/****** (Bitbucket OAuth for multibranch pipeline)
      Initialized PR: https://bitbucket.org/something/other/pull-requests/3649
      Looking up something/other for pull requests
      Checking PR-3649 from something/other and branch bugfix/SRCH-6152
            'Jenkinsfile' found
          Met criteria
      Scheduled build for branch: PR-3649
        1 pull requests were processed (query completed)
      [Wed Aug 06 17:23:27 UTC 2025] com.cloudbees.jenkins.plugins.bitbucket.hooks.PREvent CREATED event from 104.192.140.240 ⇒ https://jenknis.mydomain.com:8080/bitbucket-scmsource-hook/notify with timestamp Wed Aug 06 17:23:21 UTC 2025 processed in 1.2 sec
      [Wed Aug 06 17:23:30 UTC 2025] Received com.cloudbees.jenkins.plugins.bitbucket.hooks.PREvent UPDATED event from 104.192.140.240 ⇒ https://jenknis.mydomain.com:8080/bitbucket-scmsource-hook/notify with timestamp Wed Aug 06 17:23:25 UTC 2025
      Connecting to https://bitbucket.org using xh2XVc8rjZurKMzFwS/****** (Bitbucket OAuth for multibranch pipeline)
      Initialized PR: https://bitbucket.org/something/other/pull-requests/3649
      Looking up something/other for pull requests
      Checking PR-3649 from something/other and branch bugfix/SRCH-6152
            'Jenkinsfile' found
          Met criteria
      No changes detected: PR-3649 (still at 3a74f1e5f6c9+7f94d5bea397)
        1 pull requests were processed (query completed)
      [Wed Aug 06 17:23:31 UTC 2025] com.cloudbees.jenkins.plugins.bitbucket.hooks.PREvent UPDATED event from 104.192.140.240 ⇒ https://jenknis.mydomain.com:8080/bitbucket-scmsource-hook/notify with timestamp Wed Aug 06 17:23:25 UTC 2025 processed in 1 sec
      [Wed Aug 06 17:23:34 UTC 2025] Received com.cloudbees.jenkins.plugins.bitbucket.hooks.PREvent REMOVED event from 104.192.140.240 ⇒ https://jenknis.mydomain.com:8080/bitbucket-scmsource-hook/notify with timestamp Wed Aug 06 17:23:29 UTC 2025
      Connecting to https://bitbucket.org using xh2XVc8rjZurKMzFwS/****** (Bitbucket OAuth for multibranch pipeline)
      Looking up something/other for pull requests
        0 pull requests were processed
      [Wed Aug 06 17:23:34 UTC 2025] com.cloudbees.jenkins.plugins.bitbucket.hooks.PREvent REMOVED event from 104.192.140.240 ⇒ https://jenknis.mydomain.com:8080/bitbucket-scmsource-hook/notify with timestamp Wed Aug 06 17:23:29 UTC 2025 processed in 0.24 sec 

      However the jobs remain in this state forever unless i delete them manually or trigger a manual scan.
      My understanding of the documentation is that with these settings the builds should be automatically removed. Am i missing something?

      Best Regards

        1. Screenshot_20250807_164625.png
          92 kB
          Atanas Zhelev
        2. Screenshot_20250807_164658.png
          104 kB
          Atanas Zhelev

            Unassigned Unassigned
            azhelev Atanas Zhelev
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: