Saturday, April 18, 2020

Trigger Jenkins Job from Slack - How to Trigger Jenkins Build Job from Slack

Jenkins job can be triggered in many ways using poll SCM, webhooks. Well, you can also trigger a Jenkins job from Slack as well.  Let us see how to achieve that.

1. Install build authorization token root plug-in under Manager Jenkins --> Manage Plug-ins
2. Make sure you have already created a channel in Slack.

Now let us look at the steps on how to trigger Jenkins Job from Slack channel:

Steps in Jenkins:

1. Go to Jenkins --> Click on the Job you would like to trigger from Slack --> Configure
Go to build triggers section.

We will be using the following URL to trigger builds from Slack

2. Go to Manage Jenkins --> Configure Global security, click on Allow anonymous read only access.
Apply, Save.

Steps in Slack:

1. Go to the channel from where you would like to trigger builds.
2. Channel settings --> Click on More --> Click Add apps
Type slash commands and add it

Click on view in app directory

Click on Add to Slack

Enter a command - single word something like /build (it should be one word no spaces or characters)

Click on Add Slash command integration
Enter Jenkins URL, like mentioned above -

Method as GET

and scroll down click on the check box like below

And click Save Integration

Go to channel, enter the command as shown below:

and press enter

Now your Jenkins job should run instantly in Jenkins. 

You can watch this steps in my YouTube channel as well:

1 comment:

  1. I tried above methods in jenkins localhost:8080, I can't able to trigger jobs using slash comands, getting 'dispatch fail' error in slack. Whether it is not suit for localhost:8080? or it is suitable only for jenkins install in in server (EC2 instance).