Merge "Add support for jms_messaging builder and publisher"

This commit is contained in:
Jenkins 2017-05-23 14:37:15 +00:00 committed by Gerrit Code Review
commit a02b20cd36
12 changed files with 242 additions and 0 deletions

View File

@ -3254,6 +3254,50 @@ def cloudformation(registry, xml_parent, data):
region_dict)
def jms_messaging(registry, xml_parent, data):
"""yaml: jms-messaging
The JMS Messaging Plugin provides the following functionality:
- A build trigger to submit jenkins jobs upon receipt
of a matching message.
- A builder that may be used to submit a message to the topic
upon the completion of a job
- A post-build action that may be used to submit a message to the topic
upon the completion of a job
JMS Messaging provider types supported:
- ActiveMQ
- FedMsg
Requires the Jenkins :jenkins-wiki:`JMS Messaging Plugin
Pipeline Plugin <JMS+Messaging+Plugin>`.
:arg str override-topic: If you need to override the default topic.
(default '')
:arg str provider-name: Name of message provider setup in the
global config. (default '')
:arg str msg-type: A message type
(default 'CodeQualityChecksDone')
:arg str msg-props: Message header to publish. (default '')
:arg str msg-content: Message body to publish. (default '')
Full Example:
.. literalinclude::
../../tests/builders/fixtures/jms-messaging-full.yaml
:language: yaml
Minimal Example:
.. literalinclude::
../../tests/builders/fixtures/jms-messaging-minimal.yaml
:language: yaml
"""
helpers.jms_messaging_common(xml_parent, 'com.redhat.jenkins.plugins.ci.'
'CIMessageBuilder', data)
def openshift_build_verify(registry, xml_parent, data):
"""yaml: openshift-build-verify
Performs the equivalent of an 'oc get builds` command invocation for the

View File

@ -522,3 +522,29 @@ def convert_mapping_to_xml(parent, data, mapping, fail_required=False):
XML.SubElement(parent, xmlname).text = str(valid_dict[val])
else:
XML.SubElement(parent, xmlname).text = str(val)
def jms_messaging_common(parent, subelement, data):
"""JMS common helper function
Pass the XML parent and the specific subelement from the builder or the
publisher.
data is passed to mapper helper function to map yaml fields to XML fields
"""
namespace = XML.SubElement(parent,
subelement)
if 'override-topic' in data:
overrides = XML.SubElement(namespace, 'overrides')
XML.SubElement(overrides,
'topic').text = str(data.get('override-topic', ''))
mapping = [
# option, xml name, default value
("provider-name", 'providerName', ''),
("msg-type", 'messageType', 'CodeQualityChecksDone'),
("msg-props", 'messageProperties', ''),
("msg-content", 'messageContent', ''),
]
convert_mapping_to_xml(namespace, data, mapping, fail_required=True)

View File

@ -6652,6 +6652,50 @@ def phabricator(registry, xml_parent, data):
data.get('comment-with-console-link-on-failure')).lower()
def jms_messaging(registry, xml_parent, data):
"""yaml: jms-messaging
The JMS Messaging Plugin provides the following functionality:
- A build trigger to submit jenkins jobs upon receipt
of a matching message.
- A builder that may be used to submit a message to the topic
upon the completion of a job
- A post-build action that may be used to submit a message to the topic
upon the completion of a job
JMS Messaging provider types supported:
- ActiveMQ
- FedMsg
Requires the Jenkins :jenkins-wiki:`JMS Messaging Plugin
Pipeline Plugin <JMS+Messaging+Plugin>`.
:arg str override-topic: If you need to override the default topic.
(default '')
:arg str provider-name: Name of message provider setup in the
global config. (default '')
:arg str msg-type: A message type
(default 'CodeQualityChecksDone')
:arg str msg-props: Message header to publish. (default '')
:arg str msg-content: Message body to publish. (default '')
Full Example:
.. literalinclude::
../../tests/publishers/fixtures/jms-messaging-full.yaml
:language: yaml
Minimal Example:
.. literalinclude::
../../tests/publishers/fixtures/jms-messaging-minimal.yaml
:language: yaml
"""
helpers.jms_messaging_common(xml_parent, 'com.redhat.jenkins.plugins.ci.'
'CIMessageNotifier', data)
def openshift_build_canceller(registry, xml_parent, data):
"""yaml: openshift-build-canceller
This action is intended to provide cleanup for a Jenkins job which failed

View File

@ -782,6 +782,8 @@ def jms_messaging(registry, xml_parent, data):
The JMS Messaging Plugin provides the following functionality:
- A build trigger to submit jenkins jobs upon receipt
of a matching message.
- A builder that may be used to submit a message to the topic
upon the completion of a job
- A post-build action that may be used to submit a message to the topic
upon the completion of a job

View File

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<builders>
<com.redhat.jenkins.plugins.ci.CIMessageBuilder>
<overrides>
<topic>org.centos.stage.ci.pipeline.compose.complete</topic>
</overrides>
<providerName>fedmsg</providerName>
<messageType>Custom</messageType>
<messageProperties>topic=org.centos.prod.ci.pipeline.compose.complete
username=fedora-atomic
</messageProperties>
<messageContent>{
&quot;build_url&quot;: &quot;${BUILD_URL}&quot;,
&quot;compose_url&quot;: &quot;&lt;full-url-to-compose&gt;&quot;,
&quot;build_id&quot;: &quot;${BUILD_ID}&quot;,
&quot;ref&quot;: &quot;fedora/rawhide/${basearch}/atomic-host&quot;,
&quot;rev&quot;: &quot;&lt;sha of the commit from dist-git&gt;&quot;,
&quot;namespace&quot;: &quot;rpms&quot;,
&quot;repo&quot;: &quot;php-simplepie&quot;,
&quot;status&quot;: &quot;&lt;success/failure/aborted&gt;&quot;,
&quot;test_guidance&quot;: &quot;&lt;comma-separated-list-of-test-suites-to-run&gt;&quot;}
}</messageContent>
</com.redhat.jenkins.plugins.ci.CIMessageBuilder>
</builders>
</project>

View File

@ -0,0 +1,20 @@
builders:
- jms-messaging:
override-topic: org.centos.stage.ci.pipeline.compose.complete
provider-name: fedmsg
msg-type: Custom
msg-props: |
topic=org.centos.prod.ci.pipeline.compose.complete
username=fedora-atomic
msg-content: |
{
"build_url": "${BUILD_URL}",
"compose_url": "<full-url-to-compose>",
"build_id": "${BUILD_ID}",
"ref": "fedora/rawhide/${basearch}/atomic-host",
"rev": "<sha of the commit from dist-git>",
"namespace": "rpms",
"repo": "php-simplepie",
"status": "<success/failure/aborted>",
"test_guidance": "<comma-separated-list-of-test-suites-to-run>"}
}

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<builders>
<com.redhat.jenkins.plugins.ci.CIMessageBuilder>
<providerName>fedmsg</providerName>
<messageType>CodeQualityChecksDone</messageType>
<messageProperties>test</messageProperties>
<messageContent>test</messageContent>
</com.redhat.jenkins.plugins.ci.CIMessageBuilder>
</builders>
</project>

View File

@ -0,0 +1,6 @@
builders:
- jms-messaging:
provider-name: fedmsg
msg-type: CodeQualityChecksDone
msg-props: test
msg-content: test

View File

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<publishers>
<com.redhat.jenkins.plugins.ci.CIMessageNotifier>
<overrides>
<topic>org.centos.stage.ci.pipeline.compose.complete</topic>
</overrides>
<providerName>fedmsg</providerName>
<messageType>Custom</messageType>
<messageProperties>topic=org.centos.prod.ci.pipeline.compose.complete
username=fedora-atomic
</messageProperties>
<messageContent>{
&quot;build_url&quot;: &quot;${BUILD_URL}&quot;,
&quot;compose_url&quot;: &quot;&lt;full-url-to-compose&gt;&quot;,
&quot;build_id&quot;: &quot;${BUILD_ID}&quot;,
&quot;ref&quot;: &quot;fedora/rawhide/${basearch}/atomic-host&quot;,
&quot;rev&quot;: &quot;&lt;sha of the commit from dist-git&gt;&quot;,
&quot;namespace&quot;: &quot;rpms&quot;,
&quot;repo&quot;: &quot;php-simplepie&quot;,
&quot;status&quot;: &quot;&lt;success/failure/aborted&gt;&quot;,
&quot;test_guidance&quot;: &quot;&lt;comma-separated-list-of-test-suites-to-run&gt;&quot;}
}</messageContent>
</com.redhat.jenkins.plugins.ci.CIMessageNotifier>
</publishers>
</project>

View File

@ -0,0 +1,20 @@
publishers:
- jms-messaging:
override-topic: org.centos.stage.ci.pipeline.compose.complete
provider-name: fedmsg
msg-type: Custom
msg-props: |
topic=org.centos.prod.ci.pipeline.compose.complete
username=fedora-atomic
msg-content: |
{
"build_url": "${BUILD_URL}",
"compose_url": "<full-url-to-compose>",
"build_id": "${BUILD_ID}",
"ref": "fedora/rawhide/${basearch}/atomic-host",
"rev": "<sha of the commit from dist-git>",
"namespace": "rpms",
"repo": "php-simplepie",
"status": "<success/failure/aborted>",
"test_guidance": "<comma-separated-list-of-test-suites-to-run>"}
}

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<publishers>
<com.redhat.jenkins.plugins.ci.CIMessageNotifier>
<providerName>fedmsg</providerName>
<messageType>CodeQualityChecksDone</messageType>
<messageProperties>test</messageProperties>
<messageContent>test</messageContent>
</com.redhat.jenkins.plugins.ci.CIMessageNotifier>
</publishers>
</project>

View File

@ -0,0 +1,6 @@
publishers:
- jms-messaging:
provider-name: fedmsg
msg-type: CodeQualityChecksDone
msg-props: test
msg-content: test