Skip to end of metadata
Go to start of metadata

Plugin Information

View RabbitMQ Build Trigger on the plugin site for more information.

Description

This plugin triggers build using remote build message in RabbitMQ queue.

Usage

This plugin needs RabbitMQ Consumer Plugin. It would be installed by dependency for this plugin. Then you need to configure it before using this plugin.

If you install this, RabbitMQ Build Trigger setting is added into your job project's build trigger section. please enable it then set your token. So build would be triggered if appropriate application message arrives.

Also adds Publish build result to RabbitMQ to Post-build Actions in your job's configuration. If you set this action, build result message is published to your specified exchange or queue in RabbitMQ. Published message is the below:

A published message has 3 properties.

content_type: application/json
app_id: remote-build
routingkey: ROUTINGKEY or org.jenkinsci.plugins.rabbitmqbuildtrigger

And has 1 key in message header.

jenkins-url: JENKINS_ROOT_URL
{
    "project": "PROJECTNAME",
    "number": "BUILDNUMBER",
    "status": "SUCCESS|FAILURE|UNSTABLE.."
}

Application Message Format

A message must have two properties.

content_type: application/json
app_id: remote-build
{
  "project": "RPROJECTNAME",
  "token": "TOKEN",
  "parameter": [
    {
      "name": "PARAMETERNAME",
      "value": "VALUE"
    },
    {
      "name": "PARAMETERNAME2",
      "value": "VALUE2"
    }
  ]
}

name in each parameters is compared with existing parameter name by case-insensitive.

License

MIT License.

Version history

Version 2.5 (10/12/2017)

  • PR#5: Add NullPointerException protection to the getProjectName in RemoteBuildTrigger
  • PR#7: Workflow Job compatibility

Version 2.4 (10/12/2017)

  • Deployment failed. skip.

Version 2.3 (08/19/2014)

  • Add tests
  • Bump rabbitmq-consumer to 2.5
  • Bump maven-release-plugin to 2.5
  • Add dependency: Junit and JMockit
  • Remove feature which publishes message to queue directly
    • Publisher supports exchange type broker only
  • Trigger build with no parameter in message
  • Add routing key field to job config
    • If empty, default key will be used
  • Add Jenkins URL to published message header
    • Key: "jenkins-url"

Version 2.2 (03/24/2014)

  • Bumped consumer-plugin to 2.2
  • Bumped Java to 1.6

Version 2.1 (01/27/2014)

  • Bumped consumer-plugin to 2.1
  • Bumped Jenkins to 1.532.1

Version 2.0 (01/14/2014)

  • Bumped consumer-plugin to 2.0
  • Replace old interfaces to new one.

Version 1.9 (07/23/2013)

  • Bumped consumer-plugin to 1.9

Version 1.8 (07/18/2013)

  • Bumped consumer-plugin to 1.8
  • Add feature: publish message to queue directly

Version 1.7 (07/17/2013)

  • Bumped consumer-plugin to 1.7
  • Add RemoteBuildPublisher

Version 1.6 (05/30/2013)

  • Bumped consumer-plugin to 1.6
  • Improve locking opportunity

Version 1.5 (05/30/2013)

  • Bumped consumer-plugin to 1.5
  • More tolerant behavior on empty token

Version 1.4 (04/16/2013)

  • Bumped consumer-plugin to 1.4
  • Cleanup logging messages

Version 1.3 (04/09/2013)

  • Bumped consumer-plugin to 1.3

Version 1.2 (04/09/2013)

  • Fix "Cannot update token" issue.
  • Bumped consumer-plugin to 1.2

Version 1.1 (04/01/2013)

Re-release

Version 1.0 (04/01/2013)

Initial release

7 Comments

  1. Great plugin, but if I may propose some improvements:
    * Allow custom meta data to be attached to the message by the post-build-action, using environment variables and free text. This should be configurable on system level and per job.

    One thing I don't understand is how to make the post-build-action send a message that can trigger a build using the build-trigger part of the plugin. Since the build-trigger expect a TOKEN, and the post-build-action doesn't send one, I can't see how it can be made to work. What am I missing?

    1. This plugin is a sample for rabbitmq-consumer-plugin. So this has minimum features only. Since it is this plugin's policy, I would not expand in future. Sorry.

      Since 2.3, a parameter is added to message header named "jenkins-url". Using only message, you can get whole build informations via Jenkins Remote API.

      Jenkins Remote API:

      https://wiki.jenkins-ci.org/display/JENKINS/Remote+access+API

      E.g.
      JENKINS_ROOT_URL/job/PROJECTNAME/BUILDNUMBER/api

  2. I believe I have a similar question as @per_bohlin.  Does this plugin and the RabbitMQ consumer plugin provide a way to remote trigger a job out of the box?

    I have two jenkins servers.  One on AWS and one behind our corporate firewall.  I have used the post build action on the external jenkins to publish a build result to rabbit.  This is works as expected.

    I want the jenkins behind the corporate firewall to be able to receive that message and trigger a build.  I am able to consume the message from the queue but it does not trigger the internal job because the published message does not contain the "TOKEN".  I do not see how to configure the post-build action to use a token in it's message. 

    It seems like these plugins are missing something to allow an end-to-end publish and trigger build solution.  I cannot find an example of how to set this up to have one job trigger another job through rabbitmq.  Do you know of any examples?

    1. Published message does not have format for triggering build by this plugin. You need to convert it to proper format. I have no plan to provide such feature because message publishing including message constrution should be done by part of job execution. Publishing message feature this plugin has is only simple solution to publish build result.

      Jenkins world has a lot of plugin for post build. e.g. PostBuildScript, Parameterized Build Trigger, Groovy Post Build, and so on. Using them and standalone command or script that can speak amqp, you can construct message then publish it to rabbit.

  3. I am using version 2.5, and added "rmqRemoteBuild" in my Jenkinsfile's trigger section shown in the link below. However, I am receiving the error shown below

    WorkflowScript: 8: Invalid trigger type "rmqRemoteBuild". Valid trigger types: [] line 8, column 9

    https://github.com/jenkinsci/rabbitmq-build-trigger-plugin#pipeline-support

    1. Seems document has something issue. Fixed.

      1. rin_ne - thank you for the fix. However, I still hit the issue. I tested on a free style job. It seems like rmqRemoteBuild is not trigger option even when I install the plugin.