jenkinsci / jenkinsci/workflow-multibranch-plugin

[JENKINS-61296] Milestone step should allow to optionally define build result

Open
#509 0 comments 0 reactions 0 assignees View on GitHub
component:workflow-multibranch-plugin imported-jira-issue priority:minor resolution:unresolved
Dominant language
Java
Stars
87
Forks
131
PR merge metrics
No merged PRs in 30d

Description

The milestone step cancels older builds with result NOT_BUILT.

It should be possible to optionally override this behavior and set it to something else, e.g. ABORTED.

Use case:

I want to cancel older PR builds by using this code:

def buildNumber = env.BUILD_NUMBER as int

if (buildNumber > 1) {
// aborting previous builds by superseding their milestone
milestone(buildNumber - 1)
}
// creating milestone for current build
milestone(buildNumber)

This works as expected, older builds are cancelled with result NOT_BUILT. Now I am using the Bitbucket Branch Source Plugin to automatically report the build status to Bitbucket. In that plugin, the status NOT_BUILT gets mapped to SUCCESS in Bitbucket. If I have a Merge Check to prevent merging of the PR, I now have a situation that the build result is SUCCESS even though it never ran.

So I want to be able to customize the cancelled build's result by overriding it in the milestone step.

The new parameter is optional, and if not overriden, the behavior should be exactly as it was before.

Proposed API:

milestone(, )

---
Originally reported by sebastianhaeni, imported from: Milestone step should allow to optionally define build result


  • status: Open
  • priority: Minor
  • component(s): workflow-multibranch-plugin
  • label(s): milestone, multi-branch
  • resolution: Unresolved
  • votes: 0
  • watchers: 1
  • imported: 20251212-090250

Raw content of original issue

The milestone step cancels older builds with result NOT_BUILT.

It should be possible to optionally override this behavior and set it to something else, e.g. ABORTED.

Use case:

I want to cancel older PR builds by using this code:



def buildNumber = env.BUILD_NUMBER as int

if (buildNumber > 1) {
// aborting previous builds by superseding their milestone
milestone(buildNumber - 1)
}
// creating milestone for current build
milestone(buildNumber)

This works as expected, older builds are cancelled with result NOT_BUILT. Now I am using the Bitbucket Branch Source Plugin to automatically report the build status to Bitbucket. In that plugin, the status NOT_BUILT gets mapped to SUCCESS in Bitbucket. If I have a Merge Check to prevent merging of the PR, I now have a situation that the build result is SUCCESS even though it never ran.

So I want to be able to customize the cancelled build's result by overriding it in the milestone step.
The new parameter is optional, and if not overriden, the behavior should be exactly as it was before.

Proposed API:



milestone(<ordinal>, <superseded build's result>)


Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.