diff options
author | Jenkins <jenkins@review.openstack.org> | 2016-08-29 21:43:33 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2016-08-29 21:43:33 +0000 |
commit | ad3677050fd918f6f750302e3a0cfcfd2438a672 (patch) | |
tree | 9ba20ab21394740f32c34a9cb5a6ccfa74f7af58 /jenkins_jobs | |
parent | 0545c889e14a9b259d03de20c711c7379ad7b2e0 (diff) | |
parent | eb8a54fa45aa1f20aac1207972c0159bf3b09c1a (diff) | |
download | python-jenkins-job-builder-ad3677050fd918f6f750302e3a0cfcfd2438a672.tar.gz python-jenkins-job-builder-ad3677050fd918f6f750302e3a0cfcfd2438a672.tar.xz python-jenkins-job-builder-ad3677050fd918f6f750302e3a0cfcfd2438a672.zip |
Merge "Add cancel-builds-on-update to GHPRB trigger"
Diffstat (limited to 'jenkins_jobs')
-rw-r--r-- | jenkins_jobs/modules/triggers.py | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/jenkins_jobs/modules/triggers.py b/jenkins_jobs/modules/triggers.py index 5f2f29b7..fcdf145f 100644 --- a/jenkins_jobs/modules/triggers.py +++ b/jenkins_jobs/modules/triggers.py @@ -871,6 +871,8 @@ def github_pull_request(registry, xml_parent, data): (optional) :arg string error-comment: comment to add to the PR on an errored job (optional) + :arg bool cancel-builds-on-update: cancel existing builds when a PR is + updated (optional) Example: @@ -956,9 +958,11 @@ def github_pull_request(registry, xml_parent, data): error_comment ) - # We want to have only one 'extensions' subelement, even if both status - # handling and comment handling is needed. - if requires_status or requires_job_comment: + cancel_builds_on_update = data.get('cancel-builds-on-update', False) + + # We want to have only one 'extensions' subelement, even if status + # handling, comment handling and other extensions are enabled. + if requires_status or requires_job_comment or cancel_builds_on_update: extensions = XML.SubElement(ghprb, 'extensions') # Both comment and status elements have this same type. Using a const is @@ -1028,6 +1032,11 @@ def github_pull_request(registry, xml_parent, data): error_comment) XML.SubElement(error_comment_elem, 'result').text = 'ERROR' + if cancel_builds_on_update: + XML.SubElement(extensions, + 'org.jenkinsci.plugins.ghprb.extensions.' + 'build.GhprbCancelBuildsOnUpdate') + def gitlab_merge_request(registry, xml_parent, data): """yaml: gitlab-merge-request |