22

I'm in a process of writing a Bamboo plugin, the bulk of which is complete.

The plugin works by starting a remote process off via a post request to a server and then polling the same server until it gets a message saying the process has completed or an error occurred - this part works.

I would like to add some extra logic where I can notify this server if the user cancels the job, however I'm unsure of how to go about this.

I have played about with creating another task which runs as a final task, however I don't know how to detect if any of the previous tasks failed or were cancelled.

I have tried using List<TaskResult> taskResults = taskContext.getBuildContext().getBuildResult().getTaskResults(); to get a list of the previous Task's results, however this always appears to return 0 Task Results.

I have also tried using a Post-Build Completed Action Module, however I'm unsure how I would add this to a job and the documentation on this has me slightly mystified.

If anyone could help me in the right direction I would appreciate it.

Abs
  • 56,052
  • 101
  • 275
  • 409
bScutt
  • 872
  • 8
  • 23
  • 2
    I think you should look at just creating an event listener: https://developer.atlassian.com/display/BAMBOODEV/Bamboo+Event+Listeners There's already an event there you can listen to https://docs.atlassian.com/atlassian-bamboo/2.7/com/atlassian/bamboo/event/BuildCanceledEvent.html – fogedi Feb 23 '14 at 18:02
  • @bScutt: you ll probably find more answers on https://answers.atlassian.com/ rather than posting here, but fogedi is correct. Register a listener, and listen for the BuildCanceledEvent, and post the appropriate request to the service(s) that the user cancelled. – Chii May 20 '14 at 14:35
  • @bScutt Atlassian Answers is a better place for Atlassian related questions: http://answers.atlassian.com (Note: as they currently migrate to another platform, you may not be able to post there) – Adrian Sep 02 '14 at 10:17

1 Answers1

7

From reading what you had written, I think that using an event listener is definitely the correct way to approach your problem. Below I have provided an image of my own creation that seems to describe what you have constructed and that shows where it might be best to place the event listener.

Essentially, the client of yours will issue a cancel notification to the server via its network controller mechanism. The server will then receive that cancelation notification via its network controller which is already connected to the client via some network protocol (I am assuming TCP). When that cancellation notification from the client network controller reaches the network controller of the server, the event listener in the network controller of the server will then signal the server build manager to terminate the remote build.

Diagram of your program enter image description here

I hope this helps.

A.W.
  • 186
  • 1
  • 8