Add support for jira_comment_trigger

Change-Id: I7df9e26527e2fdbeb134cdcb4c288c3ef36e341b
This commit is contained in:
Yolande Amate 2017-08-09 20:55:38 +01:00
parent 2c60aff806
commit c8f6f97d88
5 changed files with 83 additions and 0 deletions

View File

@ -1804,6 +1804,55 @@ def parameterized_timer(parser, xml_parent, data):
convert_mapping_to_xml(param_timer, data, mapping, fail_required=True)
def jira_comment_trigger(registry, xml_parent, data):
"""yaml: jira-comment-trigger
Trigger builds when a comment is added to JIRA.
Requires the Jenkins :jenkins-wiki:`JIRA Trigger Plugin
<JIRA+Trigger+Plugin>`.
:arg str jql-filter: Must match updated issues to trigger a build.
(default '')
:arg str comment-pattern: Triggers build only when the comment added to
JIRA matches pattern (default '(?i)build this please')
:arg list parameter-mapping:
:Issue Attribute Path:
* **jenkins-parameter** (`str`) -- Jenkins parameter name
(default '')
* **issue-attribute-path** (`str`) -- Attribute path (default '')
Minimal Example:
.. literalinclude::
/../../tests/triggers/fixtures/jira-comment-trigger-minimal.yaml
:language: yaml
Full Example:
.. literalinclude::
/../../tests/triggers/fixtures/jira-comment-trigger-full.yaml
:language: yaml
"""
jct = XML.SubElement(xml_parent, 'com.ceilfors.jenkins.plugins.'
'jiratrigger.JiraCommentTrigger')
jct.set('plugin', 'jira-trigger')
mapping = [
('jql-filter', 'jqlFilter', ''),
('comment-pattern', 'commentPattern', '(?i)build this please')]
convert_mapping_to_xml(jct, data, mapping, fail_required=True)
param = XML.SubElement(jct, 'parameterMappings')
for parameter in data.get('parameter-mapping', []):
parent = XML.SubElement(param, 'com.ceilfors.jenkins.plugins.'
'jiratrigger.parameter.'
'IssueAttributePathParameterMapping')
parameter_mappings = [
('jenkins-parameter', 'jenkinsParameter', ''),
('issue-attribute-path', 'issueAttributePath', '')]
convert_mapping_to_xml(
parent, parameter, parameter_mappings, fail_required=True)
class Triggers(jenkins_jobs.modules.base.Base):
sequence = 50

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<triggers class="vector">
<com.ceilfors.jenkins.plugins.jiratrigger.JiraCommentTrigger plugin="jira-trigger">
<jqlFilter>filter</jqlFilter>
<commentPattern>comment</commentPattern>
<parameterMappings>
<com.ceilfors.jenkins.plugins.jiratrigger.parameter.IssueAttributePathParameterMapping>
<jenkinsParameter>param1</jenkinsParameter>
<issueAttributePath>path/to/attribute</issueAttributePath>
</com.ceilfors.jenkins.plugins.jiratrigger.parameter.IssueAttributePathParameterMapping>
</parameterMappings>
</com.ceilfors.jenkins.plugins.jiratrigger.JiraCommentTrigger>
</triggers>
</project>

View File

@ -0,0 +1,7 @@
triggers:
- jira-comment-trigger:
jql-filter: filter
comment-pattern: comment
parameter-mapping:
- jenkins-parameter: param1
issue-attribute-path: 'path/to/attribute'

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<triggers class="vector">
<com.ceilfors.jenkins.plugins.jiratrigger.JiraCommentTrigger plugin="jira-trigger">
<jqlFilter/>
<commentPattern>(?i)build this please</commentPattern>
<parameterMappings/>
</com.ceilfors.jenkins.plugins.jiratrigger.JiraCommentTrigger>
</triggers>
</project>

View File

@ -0,0 +1,2 @@
triggers:
- jira-comment-trigger