Integrating with Mattermost

Mattermost is the number one open source Slack alternative, and can be hosted on a proprietary platform that you manage yourself.

When teams use these tools, they can become more productive because of direct communication via chat in specialized channels. There, they can exchange quick information bits  even files (images/video, anything) and datafiles that are used by applications.

You can use Mattermost via a browser, or use the platform-specific app on your mobile device. No specific personal data is used other than your email address. 

What is also one of its killer features is that it easily connects to third-party applications and systems such as GitLab, Jira Jenkins, Nagios, Zabbix, Kopano, and many more! The company has actually been bought by GitLab, and Mattermost is part of the omnibus installation. In other words, you can easily enable it and run it together with GitLab. ChatOps has been supported since GitLab Ultimate 10.6, but came to GitLab Core in 11.9.

As an example, we will set up a new Mattermost server to integrate with a GitLab instance in order to use slash commands.

Because Mattermost is part of the GitLab omnibus package, you can enable/install it by editing the gitlab.rb file, and use gitlab-ctl afterwards to reconfigure your instance.

The configuration key to change in gitlab.rb is as follows:

mattermost['enable'] = true

After Mattermost has been started, you can go the integrations page of the settings of your project and search for the Mattermost slash command service. Click on Add to Mattermost. This will only work automatically on Mattermost 3.4, so make sure that your omnibus package isn't too old.

If Mattermost isn't installed on your server, you can pull a simple Mattermost image from Docker Hub. mattermost/mattermost-preview will do fine. Let's get started:

  1. When you log in for the first time in your container (by default, this is via http://localhost:8065), you have to create a user:

  1. After you have created the user, you will want to create a team:

  1. That team needs a URL as well:

  1. You can click the hamburger menu to reveal options for the team:

  1. Go to the system console:

  1. Look for Custom Integrations and check that slash commands are enabled. Save the settings:

  1. After this, click the hamburger menu and click Switch back to.... Clicking the hamburger menu in the team context, you can click Integrations. Here, you can click on Slash Command, where you will find a page where you can define a slash command that can be triggered by Mattermost:

  1. The information we need to fill in here can be got from GitLab:

  1. Log in to GitLab and go to Integrations in the settings part of your repository. Then, click Mattermost slash command. Here is the information you need to fill in in Mattermost:

  1. In the following screenshot, you can see the settings as we copied them. Click Save or Update when you are done:

  1. You will now be presented with a token to be used in GitLab. Copy the Mattermost token:

  1. Paste it into the settings page for your Mattermost integration in GitLab, and save the changes:

  1. Now, go to your team channel in Mattermost and press /. If you issue /gitlab help, Mattermost will ask you to connect your GitLab account:

  1. You will be redirected to GitLab, where you will have to authorize the connection:

  1. Now, by going back to Mattermost and issuing /gitlab help once more, you will be presented with the options for the command. There are several, and these can help your support people run ChatOps:

  1. Let's create a new issue called gitlab issue new test:

  1. If you go back to GitLab, you will find that a new issue has been created for the GitLab project:

The ultimate integration is to use CI command functions, as described here: https://docs.gitlab.com/ee/ci/chatops/

Since GitLab 11.9, ChatOps is even part of GitLab Core, so its functionality isn't limited to the GitLab Enterprise Edition.

In this section, we have showed you how to integrate your GitLab repository issues with the Mattermost chat application. There are endless possibilities if you create your own slash commands. Now, let's take a look at using webhooks for events.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.1.158