Praqma / tracey-jenkins-trigger-plugin

Jenkins RabbitMQ trigger for Tracey project
MIT License
0 stars 2 forks source link

maintainer: alexsedova

Build Status

Usage

Download the snapshot release from Github releases and install it on Jenkins by uploading the hpi file.

Plugin is not yet officially released through the Jenkins CI update center.

RabbitMQ Jenkins Trigger for Tracey

This plugin allows you to trigger jobs using RabbitMQ.

Configuring the trigger

You need to add at least one server. That is done using the global configuration on Jenkins. It is only RabbitMQ host available now

Global configuration

Then you need to enable RabbitMQ trigger on your job

Job configuration

That's it. You're good to go.

Configuring the trigger using the Jenkins Job DSL plugin

You can configure the Tracey trigger using Jenkins Job DSL:

job('tracey-job') {
    triggers {
        tracey('exchangeName', 'exchangeType', 'rabbitmq-id') {
            injectEnvironment {
                payloadKey 'MY_PAYLOAD_ENV_KEY'
                payloadInjection "FOO (foo)*", "BAR [BAR]*"
            }
            filters {
                payloadRegex '\\d{5}'
                payloadKeyValue('name', 'value')
                payloadJSONRegex '$..*[?(@.id == 2)]'
            }
        }
    }
}

The rabbitmq host id is the unique identifier assigned to the configured host. You can set this value yourself by expanding the 'Advanced' tab in the host configuration.

Environment

You can add the content of the received message as an environment variable to your build by checking the Add payload to environment checkbox.

Filters

We also provide the option to add filters to the trigger. Currently we have three types of filters. Filters

The first is a Payload regex filter that compares the contents of a message and parses it using the configured regex. If the payload matches the provided regex, then this message triggers the job, otherwise not.

The second filter is a JSON Basic filter that looks to see if json-format message is match key:value format.

The third filter is a JSON Regex filter that looks to see if json-format message is match regex expression. More information you may find here

Filters are applied in order. If one of your choices rejects the payload and the message received, the message will not trigger this project.

Self contained demo project

We also provide a self contained demo project for tracey. This demo requires docker with docker compose to work. You can find the repository here

In order to get this up and running:

git clone git@github.com:Praqma/tracey.git
cd tracey
docker-compose up

That should do it. Now you have a jenkins running on port 8080, a configured rabbitmq server and a configured job. Login details are (jenkins/demo).

Releasing

To release a new version of this CLI on Github release you need to tag the commit to release. This will be picked up by Travis CI.

Github auth for Travis release

Release is done a ReleasePraqma user and was securely created using travis setup releases

$ travis setup releases
Detected repository as Praqma/tracey-protocol-eiffel-cli-generator, is this correct? |yes| yes
Username: ReleasePraqma
Password for ReleasePraqma: **********
File to Upload: build/libs/tracey-protocol-eiffel-cli-generator.jar
Deploy only from Praqma/tracey-protocol-eiffel-cli-generator? |yes| yes
Encrypt API key? |yes| yes