jenkinsci / ghprb-plugin

github pull requests builder plugin for Jenkins
https://plugins.jenkins.io/ghprb/
MIT License
502 stars 608 forks source link

Canceling Downstream jobs on update to open Pull Request #704

Open kaleb-himes opened 6 years ago

kaleb-himes commented 6 years ago

First of all I would like to say thank you for the excellent plugin!

We have one request (if it's not already an option and I missed it somehow).

Details and background: We have about 14 tests we run on each new Pull Request (PR), and each test has a unique status that it sets. For optimization reasons we decided it best to have only one job that was running the GHPRB, we call this job the manager.

Once the manager sees a new PR or an update to an existing PR it launches the 14 downstream jobs and passes along the environment variables so each downstream job which uses the "Set GitHub commit status with custom context and message (Must configure upstream job using GHPRB trigger)" can update the status accordingly. This all works wonderfully and as expected.

Back when we used to have 14 jobs each using the GHPRB add-on we used the option "Cancel Build on Update" for those occasions when a PR was opened and then a new commit was added to the same PR before the first round of tests were complete. Some of our tests can take up to 45 minutes and we wanted to optimize our backend resources. This worked great also and is still set in the "Manager" project today.

The thing we noticed however is that since we updated to this new model the downstream jobs no longer use a trigger, and there is no option that we have found to "Cancel Build on Update" with this setup.

Feature Enhancement Request: Would it be possible to add an option to "Cancel Build on Update" for downstream jobs using the "Set GitHub commit status with custom context and message (Must configure upstream job using GHPRB trigger)" option?

saikirankv commented 6 years ago

@kaleb-himes I'm also facing the same issue, the alternate way to achieve this is by using Jenkins pipeline instead of downstream jobs.

saikirankv commented 6 years ago

in jenkins pipeline if you kill the parent job, child jobs will be automatically terminated.

kaleb-himes commented 6 years ago

Thank you both for your recommendation. I will explore conversion of all existing "FreeStyle" jobs to "Pipeline" jobs. Still it would be nice to have a similar option for the FreeStyle job builds so I will keep the request open for now.

kaleb-himes commented 6 years ago

@saikirankv,

Reviewing the pipeline syntax I don't see any option for github pull request builder which is used to launch the manager project I referenced. How are you controlling launch of your test in pipeline?

https://test.wolfssl.com/jenkins/job/PRB-pipeline/pipeline-syntax/

saikirankv commented 6 years ago

it should be a part of Build Triggers not as part of pipeline step Build Triggers -> GitHub Pull Request Builder