Skip to content
This repository has been archived by the owner on Dec 15, 2021. It is now read-only.

[JENKINS-27039] Option for stage step to cancel older executions #177

Closed
wants to merge 4 commits into from

Conversation

kreinloo
Copy link

JENKINS-27039

Added eager flag to stage step. When a new build enters this stage, it will cancel any running build so that it could proceed on its own. Inspired by @jglick's comment.

Example:

stage name: 'build', eager: true
input message: 'Proceed?'

…ly in this stage and takes its place. Inspired by JENKINS-27039.
@jglick
Copy link
Member

jglick commented Aug 12, 2015

This definitely needs coverage in StageStepTest.

@@ -41,6 +41,7 @@

public final String name;
@DataBoundSetter public @CheckForNull Integer concurrency;
@DataBoundSetter public @CheckForNull Boolean eager;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

boolean suffices (especially as the default remains false).

@jglick
Copy link
Member

jglick commented Aug 18, 2015

Looks good so far. Marking WiP pending test coverage (whether written by you or me or someone else).

@kreinloo
Copy link
Author

As of now, it still cancels jobs with the ABORTED message.

Running: End of Workflow
Rejected by SYSTEM
Finished: ABORTED

I tried using the FlowExecution.interrupt as well, but the results were the same. Probably did something wrong. I'll try to improve it and write tests as well.

@jglick
Copy link
Member

jglick commented Aug 21, 2015

StageTest IIRC.

Logic for handling aborts is a little subtle. Might need to check with a debugger why it is getting ABORTED. I suspect stop is called on the Execution and this overrides the cancellation cause you tried to set.

@witokondoria
Copy link
Member

Wouldnt it be nice to merge this feature and handle the exit status on a different issue (IMHO ABORTED fits well)

@jglick
Copy link
Member

jglick commented Oct 23, 2015

Exit status is a minor issue (mainly consistency with the current behavior), but tests are vital.

@jglick
Copy link
Member

jglick commented Jan 20, 2016

support/src/test/java/org/jenkinsci/plugins/workflow/support/steps/StageStepTest.java only tests configuration. This tests runtime behavior, the interesting stuff.

@witokondoria
Copy link
Member

What about another parameter to flag a stage as uncancellable? It could serve to define complex-one level semaphores

@amuniz
Copy link
Member

amuniz commented Feb 25, 2016

Tested locally, it works as advertised.
@kreinloo I'm going to add some tests and will file a new PR based on this one (keeping your commits).

@amuniz
Copy link
Member

amuniz commented Mar 4, 2016

Changed my mind. I'm working on a new step (milestone) that supersedes this PR. See JENKINS-27039 comments for more context.

@amuniz
Copy link
Member

amuniz commented Mar 4, 2016

See #355

@jglick jglick mentioned this pull request Mar 7, 2016
3 tasks
@jenkinsadmin
Copy link
Member

Thank you for this pull request! Please check this document for how the Jenkins project handles pull requests.

@jglick
Copy link
Member

jglick commented May 3, 2016

I think this has become obsolete; please try out jenkinsci/pipeline-milestone-step-plugin#1 and let us know if it works for you.

@jglick jglick closed this May 3, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
5 participants