postbuildscript-plugin icon indicating copy to clipboard operation
postbuildscript-plugin copied to clipboard

Abort build when a build step is interrupted

Open hashar opened this issue 1 year ago • 1 comments

Before submitting a pull request, please make sure the following is done:

  1. Fork the repository and create your branch from master.
  2. If you've fixed a bug or added code that should be tested, please add JUnit tests.
  3. Ensure the test suite passes (mvn clean verify).
  4. Run mvn hpi:run and go to http://localhost:8080/jenkins/ to test your changes. Add a job that produces your bug / feature scenario.

hashar avatar Nov 12 '24 11:11 hashar

~~The test fails somehow, I am running mvn compile -Dtest='PostBuildScriptIT#handlesInterruptedException' test and looking at the build console:~~ ~~

Expected: a string containing "foo"
     but: was "Legacy code started this job.  No cause information is available
Running as SYSTEM
Building in workspace /home/hashar/projects/jenkinsci/postbuildscript-plugin/target/tmp/j h11551619371799314393/workspace/test0
[PostBuildScript] - [INFO] Executing post build scripts.
FATAL: class org.jenkinsci.plugins.postbuildscript.PostBuildScript is missing its descriptor
java.lang.AssertionError: class org.jenkinsci.plugins.postbuildscript.PostBuildScript is missing its descriptor
	at jenkins.model.Jenkins.getDescriptorOrDie(Jenkins.java:1651)
	at hudson.tasks.Publisher.getDescriptor(Publisher.java:125)
	at hudson.tasks.Notifier.getDescriptor(Notifier.java:54)
	at hudson.tasks.Notifier.getDescriptor(Notifier.java:48)
	at hudson.model.AbstractBuild$AbstractBuildExecution.getBuildStepName(AbstractBuild.java:853)
	at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:831)
	at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:767)
	at hudson.model.Build$BuildExecution.post2(Build.java:179)
	at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:711)
	at hudson.model.Run.execute(Run.java:1917)
	at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:44)
	at hudson.model.ResourceController.execute(ResourceController.java:101)
	at hudson.model.Executor.run(Executor.java:442)
Finished: FAILURE
"

~~ ~~With mvn hpi:run, when using the parameterized trigger plugin, the build step is a job which can be waiting in the Jenkins build queue. If it gets cancelled that throws an InterruptedException and the console shows:~~ ~~

Started by user unknown or anonymous
Running as SYSTEM
Building in workspace /home/hashar/projects/jenkinsci/postbuildscript-plugin/work/workspace/strict-upstream-project
[PostBuildScript] - [INFO] Executing post build scripts.
Waiting for the completion of [downstream-project](http://127.0.0.1:8080/jenkins/job/downstream-project/)
Build aborting: cancelling queued project [downstream-project](http://127.0.0.1:8080/jenkins/job/downstream-project/)
Build step 'Execute scripts' changed build result to ABORTED
Finished: ABORTED

~~ ~~The job is described as Execute scripts. So my guess is the TestBuilder is missing something?~~

hashar avatar Nov 12 '24 11:11 hashar