Thursday, January 14, 2016

Jenkins + Slack + Fortune


I love Jenkins, and I love Slack. But the stock Slack build message is boring as hell. If you feel the same way, here's how to get a fun message to follow the notification:
  1. Install Jenkins, the Slack notification plugin, and importantly the EnvInject plugin.
  2. Configure job to notify slack on build success, failure, etc. 
  3. Add an "Execute Shell" build step, which runs your witty command writes it to a file as an environment variable.
    Tip: Surround your message with ``` to format it nicely in Slack.
  4. Add an "Inject env variables" build step to pull in the file created in the previous step.
  5. Add the environment variable to the Jenkins Slack custom message.
There you go! Here's what those steps look like. I'm using the UNIX fortune command for these:
This Jenkins setup populates an environment variable with a fun message.

This publishes the environment variable to Slack.

0 comments:

Post a Comment

Share your thoughts!