Add cancel-builds-on-update to GHPRB trigger

Change-Id: I05c2643622f469d105d53751780b0445527faf0f
This commit is contained in:
Dominic Cleal 2016-08-25 11:20:44 +01:00
parent c73cb4686a
commit eb8a54fa45
No known key found for this signature in database
GPG Key ID: 7C7D326F2C2B72CC
3 changed files with 14 additions and 3 deletions

View File

@ -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

View File

@ -54,6 +54,7 @@ org2</orgslist>
</org.jenkinsci.plugins.ghprb.extensions.comments.GhprbBuildResultMessage>
</messages>
</org.jenkinsci.plugins.ghprb.extensions.comments.GhprbBuildStatus>
<org.jenkinsci.plugins.ghprb.extensions.build.GhprbCancelBuildsOnUpdate/>
</extensions>
</org.jenkinsci.plugins.ghprb.GhprbTrigger>
</triggers>

View File

@ -27,3 +27,4 @@ triggers:
success-status: 'success status!'
failure-status: 'failure status :('
error-status: 'error status?!'
cancel-builds-on-update: true