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

Option to cancel builds when orphaning items

    XMLWordPrintable

Details

    • cloudbees-folder 6.708.ve61636eb_65a_5

    Description

      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.

      Attachments

        Issue Links

          Activity

            jglick Jesse Glick added a comment -

            kon indeed acc. to https://www.jenkins.io/doc/developer/extensions/cloudbees-folder/#orphaneditemstrategy that is the only known implementation. Anyway I think it should not matter since marking a branch dead already disables the branch project (no new builds possible) independently of orphaning. So it makes sense to me to have this code path also cancel/abort builds of that project.

            jglick Jesse Glick added a comment - kon indeed acc. to https://www.jenkins.io/doc/developer/extensions/cloudbees-folder/#orphaneditemstrategy that is the only known implementation. Anyway I think it should not matter since marking a branch dead already disables the branch project (no new builds possible) independently of orphaning. So it makes sense to me to have this code path also cancel/abort builds of that project.

            If the build is doing some kind of deployment, then the user might want to let it run to the end, even if no new builds can be started. So if DefaultOrphanedItemStrategy.abortBuilds is false then I think the MultiBranchProject should not abort builds when it disables the job.

            kon Kalle Niemitalo added a comment - If the build is doing some kind of deployment, then the user might want to let it run to the end, even if no new builds can be started. So if DefaultOrphanedItemStrategy.abortBuilds is false then I think the MultiBranchProject should not abort builds when it disables the job.
            jglick Jesse Glick added a comment -

            Oh I see your point. We would need to create another option on the MultiBranchProject (or OrganizationFolder) to let users opt into this behavior.

            Perhaps it would suffice to define a JobProperty in workflow-job which would cancel/abort builds whenever the project is disabled, similar to JENKINS-43353. That is something you could control from a Jenkinsfile using properties in Scripted syntax, options in Declarative. (OK to be set near the start of build number 1, and you could conditionally enable it for example on PR builds but not on trunk builds that might be running deployments.)

            jglick Jesse Glick added a comment - Oh I see your point. We would need to create another option on the MultiBranchProject (or OrganizationFolder ) to let users opt into this behavior. Perhaps it would suffice to define a JobProperty in workflow-job which would cancel/abort builds whenever the project is disabled, similar to JENKINS-43353 . That is something you could control from a Jenkinsfile using properties in Scripted syntax, options in Declarative. (OK to be set near the start of build number 1, and you could conditionally enable it for example on PR builds but not on trunk builds that might be running deployments.)
            kon Kalle Niemitalo added a comment - - edited

            I imagine one could have options at the pipeline level asking to abort builds, but override it with another options locally in the stage that does the deployment. Then the run would be OK to abort if it has not reached that stage yet, or has already completed it. That might be complex to implement though, especially with nested or parallel stages.

            kon Kalle Niemitalo added a comment - - edited I imagine one could have options at the pipeline level asking to abort builds, but override it with another options locally in the stage that does the deployment. Then the run would be OK to abort if it has not reached that stage yet, or has already completed it. That might be complex to implement though, especially with nested or parallel stages.
            jglick Jesse Glick added a comment -

            Yeah that sounds tricky to implement (and a complex UX too), though possible in principle.

            jglick Jesse Glick added a comment - Yeah that sounds tricky to implement (and a complex UX too), though possible in principle.

            People

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

              Dates

                Created:
                Updated:
                Resolved: