• cloudbees-folder 6.708.ve61636eb_65a_5

      It would be great to have the option to cancel builds when the orphaning is calculated. That is in DefaultOrphanedItemStrategy.java -> orphanedItems it checks whether it is currently building and skips the item (I would like to see that the build can be canceled).

      We are using the gerrit-code-review-plugin and having such an option would save us CPU resources when a new patch set is uploaded as the build result of the old patch set becomes obsolete once the new one is uploaded.

          [JENKINS-60677] Option to cancel builds when orphaning items

          John V created issue -
          Francisco Fernández made changes -
          Assignee Original: Francisco Fernández [ fcojfernandez ]
          Réda Housni Alaoui made changes -
          Status Original: Open [ 1 ] New: In Progress [ 3 ]
          Réda Housni Alaoui made changes -
          Status Original: In Progress [ 3 ] New: In Review [ 10005 ]

          Réda Housni Alaoui added a comment - Pull request opened at  https://github.com/jenkinsci/cloudbees-folder-plugin/pull/197
          Jesse Glick made changes -
          Assignee New: Réda Housni Alaoui [ reda_alaoui ]
          Jesse Glick made changes -
          Resolution New: Fixed [ 1 ]
          Status Original: In Review [ 10005 ] New: Fixed but Unreleased [ 10203 ]

          cloudbees-folder 6.708.ve61636eb_65a_5 was released.

          Kalle Niemitalo added a comment - cloudbees-folder 6.708.ve61636eb_65a_5 was released.
          Kalle Niemitalo made changes -
          Released As New: cloudbees-folder 6.708.ve61636eb_65a_5
          Status Original: Fixed but Unreleased [ 10203 ] New: Resolved [ 5 ]

          This doesn't work quite perfectly yet, with Jenkins 2.319.3, Folders Plugin 6.708.ve61636eb_65a_5, and Bitbucket Branch Source Plugin 751.vda_24678a_f781. I configured the "Orphaned Item Strategy" settings of a Multibranch Pipeline project as follows:

          • Abort builds: yes
          • Discard old items: yes
            • Days to keep old items: empty
            • Max # of old items to keep: empty

          I opened a pull request, and Jenkins created a job for the pull request and added build #1 to the queue. Because the agents were busy, the build did not start yet. I then merged the pull request, and Jenkins immediately disabled the pull request job. However, build #1 was still in the queue. Finally, I clicked "Scan Multibranch Pipeline Now". Jenkins then removed Build #1 from the queue and deleted the pull request job.

          It would be better to cancel the build immediately when the job is orphaned and disabled, not only when the job is deleted. I don't know whether it's possible to implement that just in cloudbees-folder-plugin or whether it would need changes in branch-api-plugin or workflow-multibranch-plugin as well.

          The current implementation is in the DefaultOrphanedItemStrategy.orphanedItems method, which logs "Evaluating orphaned items". I got that log entry to "Scan Multibranch Pipeline Log" but not to "Multibranch Pipeline Events". Perhaps that means the orphanedItems method is not called during the webhook event.

          Kalle Niemitalo added a comment - This doesn't work quite perfectly yet, with Jenkins 2.319.3, Folders Plugin 6.708.ve61636eb_65a_5, and Bitbucket Branch Source Plugin 751.vda_24678a_f781. I configured the "Orphaned Item Strategy" settings of a Multibranch Pipeline project as follows: Abort builds: yes Discard old items: yes Days to keep old items: empty Max # of old items to keep: empty I opened a pull request, and Jenkins created a job for the pull request and added build #1 to the queue. Because the agents were busy, the build did not start yet. I then merged the pull request, and Jenkins immediately disabled the pull request job. However, build #1 was still in the queue. Finally, I clicked "Scan Multibranch Pipeline Now". Jenkins then removed Build #1 from the queue and deleted the pull request job. It would be better to cancel the build immediately when the job is orphaned and disabled, not only when the job is deleted. I don't know whether it's possible to implement that just in cloudbees-folder-plugin or whether it would need changes in branch-api-plugin or workflow-multibranch-plugin as well. The current implementation is in the DefaultOrphanedItemStrategy.orphanedItems method, which logs "Evaluating orphaned items". I got that log entry to "Scan Multibranch Pipeline Log" but not to "Multibranch Pipeline Events". Perhaps that means the orphanedItems method is not called during the webhook event.

            reda_alaoui Réda Housni Alaoui
            johnv John V
            Votes:
            3 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: