This repository is contains a Python Flask application that powers a slash command for Mattermost that allows you to view and run builds on a Jenkins server.
Import Note: This application is not really designed for production use. It is meant only to demonstrate how to connect Mattermost and Jenkins together easily using commonly available tools like Python and Flask (http://flask.pocoo.org/).
In order to use this slash command on your Mattermost server you will need:
If you have the two things above you can proceed to the installation steps below:
The following steps
git clone https://github.com/cvitter/mattermost-jenkins-slash.git
;config.sample
file to config.json
;config.json
to set the URL for your Jenkins server and the user name and password of the account you will use to access it;sudo python jenkins.py >> jenkins.log 2>&1 &
Note: When the application is running you can test it locally by posting data to it using curl like the following example:
curl -X POST -F "text=build mattermost-test-1" http://127.0.0.1:5002/jenkins
Now that the Flask application is running you have to configure your slash command in Mattermost to connect to the application. Inside of Mattermost:
Once the slash command is set up it is quite easy to use. If you have any questions you can simply
type /jenkins
will return command help as shown in the screenshot below:
If you want to view the list of items (jobs and folders) on your Jenkins server you can type:
/jenkins list
If you leave off the folder/job parameter like in the above example Jenkins will return the list of objects in the server's root like shown below:
If you want to see what is in the Level1 folder you would type:
/jenkins list Level1
To schedule a build (to run immediately) you can type:
/jenkins build mattermost-test-1
If the job succeeds you will see the following response:
If the slash command fails it should return an HTTP error code as shown in the screen shot below if the resource can't be found on the Jenkins server.
Help! If you like this project and want to make it even more awesome please contribute your ideas, code, etc.
If you have any questions, feedback, suggestions, etc. please submit them via issues here: https://github.com/cvitter/mattermost-jenkins-slash/issues
If you find errors please feel to submit pull requests. Any help in improving this resource is appreciated!
The content in this repository is Open Source material released under the MIT License. Please see the LICENSE file for full license details.
The code in this repository is not sponsored or supported by Mattermost, Inc.
Please submit Issues and/or Pull Requests.