Add addTestResults to GitHub pull request builder trigger
Also fix bug when multiple extensions are used Change-Id: I1915304b82c2d3c77d23bf4b43ac9fe5ec07f32d
This commit is contained in:
parent
fda76531d9
commit
9874bdd07f
jenkins_jobs/modules
tests/triggers/fixtures
@ -858,6 +858,8 @@ def github_pull_request(parser, xml_parent, data):
|
||||
:arg string started-status: the status comment to set when the build has
|
||||
been started (optional)
|
||||
:arg string status-url: the status URL to set (optional)
|
||||
:arg bool status-add-test-results: add test result one-liner to status
|
||||
message (optional)
|
||||
:arg string success-status: the status message to set if the job succeeds
|
||||
(optional)
|
||||
:arg string failure-status: the status message to set if the job fails
|
||||
@ -921,6 +923,7 @@ def github_pull_request(parser, xml_parent, data):
|
||||
triggered_status = data.get('triggered-status', '')
|
||||
started_status = data.get('started-status', '')
|
||||
status_url = data.get('status-url', '')
|
||||
status_add_test_results = data.get('status-add-test-results', '')
|
||||
success_status = data.get('success-status', '')
|
||||
failure_status = data.get('failure-status', '')
|
||||
error_status = data.get('error-status', '')
|
||||
@ -931,6 +934,7 @@ def github_pull_request(parser, xml_parent, data):
|
||||
triggered_status or
|
||||
started_status or
|
||||
status_url or
|
||||
status_add_test_results or
|
||||
success_status or
|
||||
failure_status or
|
||||
error_status
|
||||
@ -943,6 +947,21 @@ def github_pull_request(parser, xml_parent, data):
|
||||
error_status
|
||||
)
|
||||
|
||||
# is comment handling required?
|
||||
success_comment = data.get('success-comment', '')
|
||||
failure_comment = data.get('failure-comment', '')
|
||||
error_comment = data.get('error-comment', '')
|
||||
requires_job_comment = (
|
||||
success_comment or
|
||||
failure_comment or
|
||||
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:
|
||||
extensions = XML.SubElement(ghprb, 'extensions')
|
||||
|
||||
# Both comment and status elements have this same type. Using a const is
|
||||
# much easier to read than repeating the tokens for this class each time
|
||||
# it's used
|
||||
@ -950,7 +969,6 @@ def github_pull_request(parser, xml_parent, data):
|
||||
comment_type = comment_type + 'GhprbBuildResultMessage'
|
||||
|
||||
if requires_status:
|
||||
extensions = XML.SubElement(ghprb, 'extensions')
|
||||
simple_status = XML.SubElement(extensions,
|
||||
'org.jenkinsci.plugins'
|
||||
'.ghprb.extensions.status.'
|
||||
@ -967,6 +985,9 @@ def github_pull_request(parser, xml_parent, data):
|
||||
if status_url:
|
||||
XML.SubElement(simple_status, 'statusUrl').text = str(
|
||||
status_url)
|
||||
if status_add_test_results:
|
||||
XML.SubElement(simple_status, 'addTestResults').text = str(
|
||||
status_add_test_results).lower()
|
||||
|
||||
if requires_status_message:
|
||||
completed_elem = XML.SubElement(simple_status, 'completedStatus')
|
||||
@ -985,19 +1006,8 @@ def github_pull_request(parser, xml_parent, data):
|
||||
XML.SubElement(error_elem, 'message').text = str(error_status)
|
||||
XML.SubElement(error_elem, 'result').text = 'ERROR'
|
||||
|
||||
# comment fields
|
||||
success_comment = data.get('success-comment', '')
|
||||
failure_comment = data.get('failure-comment', '')
|
||||
error_comment = data.get('error-comment', '')
|
||||
requires_job_comment = (
|
||||
success_comment or
|
||||
failure_comment or
|
||||
error_comment
|
||||
)
|
||||
|
||||
# job comment handling
|
||||
if requires_job_comment:
|
||||
extensions = XML.SubElement(ghprb, 'extensions')
|
||||
build_status = XML.SubElement(extensions,
|
||||
'org.jenkinsci.plugins.ghprb.extensions'
|
||||
'.comments.'
|
||||
|
@ -0,0 +1,60 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<triggers class="vector">
|
||||
<org.jenkinsci.plugins.ghprb.GhprbTrigger>
|
||||
<spec>* * * * *</spec>
|
||||
<adminlist>user1
|
||||
user2</adminlist>
|
||||
<allowMembersOfWhitelistedOrgsAsAdmin>true</allowMembersOfWhitelistedOrgsAsAdmin>
|
||||
<whitelist>user3
|
||||
user4</whitelist>
|
||||
<orgslist>org1
|
||||
org2</orgslist>
|
||||
<cron>* * * * *</cron>
|
||||
<triggerPhrase>retest this please</triggerPhrase>
|
||||
<onlyTriggerPhrase>true</onlyTriggerPhrase>
|
||||
<useGitHubHooks>true</useGitHubHooks>
|
||||
<permitAll>false</permitAll>
|
||||
<autoCloseFailedPullRequests>false</autoCloseFailedPullRequests>
|
||||
<extensions>
|
||||
<org.jenkinsci.plugins.ghprb.extensions.status.GhprbSimpleStatus>
|
||||
<commitStatusContext>test status context</commitStatusContext>
|
||||
<triggeredStatus>triggered status message</triggeredStatus>
|
||||
<startedStatus>started status message</startedStatus>
|
||||
<statusUrl>http://example.com/status</statusUrl>
|
||||
<addTestResults>true</addTestResults>
|
||||
<completedStatus>
|
||||
<org.jenkinsci.plugins.ghprb.extensions.comments.GhprbBuildResultMessage>
|
||||
<message>success status!</message>
|
||||
<result>SUCCESS</result>
|
||||
</org.jenkinsci.plugins.ghprb.extensions.comments.GhprbBuildResultMessage>
|
||||
<org.jenkinsci.plugins.ghprb.extensions.comments.GhprbBuildResultMessage>
|
||||
<message>failure status :(</message>
|
||||
<result>FAILURE</result>
|
||||
</org.jenkinsci.plugins.ghprb.extensions.comments.GhprbBuildResultMessage>
|
||||
<org.jenkinsci.plugins.ghprb.extensions.comments.GhprbBuildResultMessage>
|
||||
<message>error status?!</message>
|
||||
<result>ERROR</result>
|
||||
</org.jenkinsci.plugins.ghprb.extensions.comments.GhprbBuildResultMessage>
|
||||
</completedStatus>
|
||||
</org.jenkinsci.plugins.ghprb.extensions.status.GhprbSimpleStatus>
|
||||
<org.jenkinsci.plugins.ghprb.extensions.comments.GhprbBuildStatus>
|
||||
<messages>
|
||||
<org.jenkinsci.plugins.ghprb.extensions.comments.GhprbBuildResultMessage>
|
||||
<message>success comment</message>
|
||||
<result>SUCCESS</result>
|
||||
</org.jenkinsci.plugins.ghprb.extensions.comments.GhprbBuildResultMessage>
|
||||
<org.jenkinsci.plugins.ghprb.extensions.comments.GhprbBuildResultMessage>
|
||||
<message>failure comment</message>
|
||||
<result>FAILURE</result>
|
||||
</org.jenkinsci.plugins.ghprb.extensions.comments.GhprbBuildResultMessage>
|
||||
<org.jenkinsci.plugins.ghprb.extensions.comments.GhprbBuildResultMessage>
|
||||
<message>error comment</message>
|
||||
<result>ERROR</result>
|
||||
</org.jenkinsci.plugins.ghprb.extensions.comments.GhprbBuildResultMessage>
|
||||
</messages>
|
||||
</org.jenkinsci.plugins.ghprb.extensions.comments.GhprbBuildStatus>
|
||||
</extensions>
|
||||
</org.jenkinsci.plugins.ghprb.GhprbTrigger>
|
||||
</triggers>
|
||||
</project>
|
@ -0,0 +1,29 @@
|
||||
triggers:
|
||||
- github-pull-request:
|
||||
admin-list:
|
||||
- user1
|
||||
- user2
|
||||
white-list:
|
||||
- user3
|
||||
- user4
|
||||
org-list:
|
||||
- org1
|
||||
- org2
|
||||
cron: '* * * * *'
|
||||
trigger-phrase: 'retest this please'
|
||||
only-trigger-phrase: true
|
||||
github-hooks: true
|
||||
permit-all: false
|
||||
auto-close-on-fail: false
|
||||
allow-whitelist-orgs-as-admins: true
|
||||
success-comment: 'success comment'
|
||||
failure-comment: 'failure comment'
|
||||
error-comment: 'error comment'
|
||||
status-context: 'test status context'
|
||||
triggered-status: 'triggered status message'
|
||||
started-status: 'started status message'
|
||||
status-url: 'http://example.com/status'
|
||||
status-add-test-results: true
|
||||
success-status: 'success status!'
|
||||
failure-status: 'failure status :('
|
||||
error-status: 'error status?!'
|
@ -22,6 +22,7 @@ org2</orgslist>
|
||||
<triggeredStatus>triggered status message</triggeredStatus>
|
||||
<startedStatus>started status message</startedStatus>
|
||||
<statusUrl>http://example.com/status</statusUrl>
|
||||
<addTestResults>true</addTestResults>
|
||||
<completedStatus>
|
||||
<org.jenkinsci.plugins.ghprb.extensions.comments.GhprbBuildResultMessage>
|
||||
<message>success status!</message>
|
||||
|
@ -20,6 +20,7 @@ triggers:
|
||||
triggered-status: 'triggered status message'
|
||||
started-status: 'started status message'
|
||||
status-url: 'http://example.com/status'
|
||||
status-add-test-results: true
|
||||
success-status: 'success status!'
|
||||
failure-status: 'failure status :('
|
||||
error-status: 'error status?!'
|
||||
|
Loading…
x
Reference in New Issue
Block a user