From d07ec2b2381e29de34a5275e79329bf115f04e34 Mon Sep 17 00:00:00 2001 From: Tim Birkett Date: Fri, 29 Jan 2016 00:35:04 +0000 Subject: [PATCH] Add trigger for RabbitMQ trigger module Change-Id: I4065fb95c0a54507eb079b9c92e2343237b87027 --- jenkins_jobs/modules/triggers.py | 28 +++++++++++++++++++++++++++ tests/triggers/fixtures/rabbitmq.xml | 9 +++++++++ tests/triggers/fixtures/rabbitmq.yaml | 3 +++ 3 files changed, 40 insertions(+) create mode 100644 tests/triggers/fixtures/rabbitmq.xml create mode 100644 tests/triggers/fixtures/rabbitmq.yaml diff --git a/jenkins_jobs/modules/triggers.py b/jenkins_jobs/modules/triggers.py index fa5f991c6..9f1c43fd7 100644 --- a/jenkins_jobs/modules/triggers.py +++ b/jenkins_jobs/modules/triggers.py @@ -1559,6 +1559,34 @@ def groovy_script(parser, xml_parent, data): XML.SubElement(gst, 'spec').text = str(data.get('cron', '')) +def rabbitmq(parser, xml_parent, data): + """yaml: rabbitmq + This plugin triggers build using remote build message in RabbitMQ queue. + Requires the Jenkins :jenkins-wiki:`RabbitMQ Build Trigger Plugin + `. + + :arg str token: the build token expected in the message queue (required) + + Example: + + .. literalinclude:: /../../tests/triggers/fixtures/rabbitmq.yaml + :language: yaml + """ + + rabbitmq = XML.SubElement( + xml_parent, + 'org.jenkinsci.plugins.rabbitmqbuildtrigger.' + 'RemoteBuildTrigger') + + XML.SubElement(rabbitmq, 'spec').text = '' + + try: + XML.SubElement(rabbitmq, 'remoteBuildToken').text = str( + data.get('token')) + except KeyError as e: + raise MissingAttributeError(e.arg[0]) + + class Triggers(jenkins_jobs.modules.base.Base): sequence = 50 diff --git a/tests/triggers/fixtures/rabbitmq.xml b/tests/triggers/fixtures/rabbitmq.xml new file mode 100644 index 000000000..bdf0dd89e --- /dev/null +++ b/tests/triggers/fixtures/rabbitmq.xml @@ -0,0 +1,9 @@ + + + + + + build_trigger_token + + + diff --git a/tests/triggers/fixtures/rabbitmq.yaml b/tests/triggers/fixtures/rabbitmq.yaml new file mode 100644 index 000000000..f55de557f --- /dev/null +++ b/tests/triggers/fixtures/rabbitmq.yaml @@ -0,0 +1,3 @@ +triggers: + - rabbitmq: + token: 'build_trigger_token'