Start a build in Jenkins using a Slack Command
- Start a build
/jenkins MyAwesomeApp
- Start a parameterized build
/jenkins MyAwesomeApp param1=value1 param2=value2
- Error handling when staring the build fails
- Create a new "Slash Command"
- Name command
/jenkins
- Set the URL to the url of your Heroku instance (created in step 3)
- Method should be POST
- Label should be 'Jenkins' or whatevs
- Name command
- Create a new "Inbound Webhook" (Optional)
- Set the channel you would like to post to
- Set the bot name
Jenkins
or whatevs
- Required environment variables
SLACK_TOKEN
- token from your "Slash Command"JENKINS_URL
- URL to your Heroku instnaceJENKINS_TOKEN
- API token of your user in Jenkins- The API token is available in your personal configuration page. Click your name on the top right corner on every page, then click "Configure" to see your API token. (The URL $root/me/configure is a good shortcut.) You can also change your API token from here.
- Optional environment variables
SLACK_WEBHOOK_URL
- your incoming webhook URL
/jenkins MyAwesomeApp
I used ngrok.com with basic authentication to expose my Jenkins server
You can! Make a parameterized build with a name called lane
(or whatever you want to call it). Make this a string or choice parameter with all your build lanes available as choices (beta, inhouse, app_store). Then use this $lane
in your build shell command in your job's configuration - bundle exec fasltane $lane
.
To call this from Slack, all you need to do is send /jenkins MyAwesomeApp lane=beta
.
Josh Holtz, [email protected], @joshdholtz
jenkins-slack-command is available under the MIT license. See the LICENSE file for more info.