Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JENKINS-43353] Option to disable concurrent builds by aborting previous ones #200

Merged
merged 6 commits into from
Oct 12, 2021

Conversation

jglick
Copy link
Member

@jglick jglick commented Jun 30, 2021

JENKINS-43353, more straightforward and efficient than using the previous hack

def buildNumber = BUILD_NUMBER as int; if (buildNumber > 1) milestone(buildNumber - 1); milestone(buildNumber)

Can be configured via GUI (for standalone Pipelines) or as code

properties([disableConcurrentBuilds(abortPrevious: true)])

https://github.com/jenkinsci/jenkins/blob/794770f7b27b323a42c07ae03d2cb64a0acb5a8d/core/src/main/java/hudson/model/Run.java#L352 sounds incorrect for `WorkflowRun`, which can survive restart.
https://github.com/jenkinsci/jenkins/blob/794770f7b27b323a42c07ae03d2cb64a0acb5a8d/core/src/main/java/hudson/model/Run.java#L910-L913 looks like it could break lazy-loading in some cases.
Anyway for purposes of this feature we really only care about the previous build:
there should not be _intermediate_ completed builds once this mode takes effect.
@jglick
Copy link
Member Author

jglick commented Dec 6, 2021

@cathychan & @jtnord point out that when introducing this option for the first time, say to replace the milestone trick, you leave one extra build of an existing job running because the property is only interpreted when starting a build, not when the property is added (for example via properties step in Jenkinsfile). Probably DisableConcurrentBuildsJobProperty could be improved to override setOwner to immediately abort any running build(s) other than the latest.

jakubgs added a commit to status-im/status-mobile that referenced this pull request Jun 28, 2022
jenkinsci/workflow-job-plugin#200
Removes the need to use our own convoluted implementation:
https://github.com/status-im/status-jenkins-lib/blob/17c1d0ea/vars/jenkins.groovy#L6-L27

Signed-off-by: Jakub Sokołowski <jakub@status.im>
jakubgs added a commit to status-im/status-mobile that referenced this pull request Jun 28, 2022
jenkinsci/workflow-job-plugin#200
Removes the need to use our own convoluted implementation:
https://github.com/status-im/status-jenkins-lib/blob/17c1d0ea/vars/jenkins.groovy#L6-L27

Signed-off-by: Jakub Sokołowski <jakub@status.im>
jakubgs added a commit to status-im/status-mobile that referenced this pull request Jun 28, 2022
jenkinsci/workflow-job-plugin#200
Removes the need to use our own convoluted implementation:
https://github.com/status-im/status-jenkins-lib/blob/17c1d0ea/vars/jenkins.groovy#L6-L27

Signed-off-by: Jakub Sokołowski <jakub@status.im>
jakubgs added a commit to status-im/status-mobile that referenced this pull request Jun 28, 2022
jenkinsci/workflow-job-plugin#200
Removes the need to use our own convoluted implementation:
https://github.com/status-im/status-jenkins-lib/blob/17c1d0ea/vars/jenkins.groovy#L6-L27

Signed-off-by: Jakub Sokołowski <jakub@status.im>
jakubgs added a commit to status-im/status-mobile that referenced this pull request Jun 28, 2022
jenkinsci/workflow-job-plugin#200
Removes the need to use our own convoluted implementation:
https://github.com/status-im/status-jenkins-lib/blob/17c1d0ea/vars/jenkins.groovy#L6-L27

Signed-off-by: Jakub Sokołowski <jakub@status.im>
jakubgs added a commit to status-im/status-mobile that referenced this pull request Jul 5, 2022
jenkinsci/workflow-job-plugin#200
Removes the need to use our own convoluted implementation:
https://github.com/status-im/status-jenkins-lib/blob/17c1d0ea/vars/jenkins.groovy#L6-L27

Signed-off-by: Jakub Sokołowski <jakub@status.im>
jakubgs added a commit to status-im/status-mobile that referenced this pull request Jul 13, 2022
jenkinsci/workflow-job-plugin#200
Removes the need to use our own convoluted implementation:
https://github.com/status-im/status-jenkins-lib/blob/17c1d0ea/vars/jenkins.groovy#L6-L27

Signed-off-by: Jakub Sokołowski <jakub@status.im>
jakubgs added a commit to status-im/status-mobile that referenced this pull request Jul 13, 2022
jenkinsci/workflow-job-plugin#200
Removes the need to use our own convoluted implementation:
https://github.com/status-im/status-jenkins-lib/blob/17c1d0ea/vars/jenkins.groovy#L6-L27

Signed-off-by: Jakub Sokołowski <jakub@status.im>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants