Travis-CI Slack Integration as notification for your travis-ci.org projects, you are freed from having status email plugging your account. Here is what it takes to make it running.
Though, I made it working, I was wondering if the .travis.yml file, which must be in the root folder of your repo, couldn’t be optimized (e.g. sending notifications).
See the final result
And here is what you have to do
- Slack account
- public repo on github
- have the travis gem installed ([sudo] gem install travis)
- make sure your local copy of the repos has the remote connected via https (As of this writing travis init didn’t work with a git connection)
Open the Terminal and go to the root folder of your repo and run travis login. Depending on your github account configuration you have to provide the necessary information for username/password/code for 2FA.
Now run travis init and answer all the questions truthfully. This will create a basic .travis.yml file in the root folder. It contains, for the time being, only the language: key which it derives from your project. Resist to press Enter if travis asks you for language [Swift]. In this case type objective-c and press enter.
Okay. If you want to use Slack I recommend to encrypt the API key as follows.
Go to your Slack team side and add an integration to one of your channels. Slack helps you integrating with travis-ci by providing you with the terminal command to generate an encrypted entry for your travis.yml file. It will look similar to this but we are going to extend this a little bit by adding
travis encrypt "team-name:api-key" --add notifications.slack travis encrypt "team-name:api-key#channel-name" --add notifications.slack.rooms
to have travis post it into the right channel.
Now your travis.yml file looks like this.
To further decrease the number of notifications you receive we will add two more keywords to the notifications section (on_success: and on_failure). The last thing what’s missing is the environment configuration for the build system. By default travis takes xctool so we just enter values for
xcode_project: YourProjectName.xcodeproj xcode_scheme: YourProjectName (make sure you have set the share button for the scheme in Xcode) osx_image: e.g. xcode7.2 xcode_sdk: iphonesimulator9.2
You find all possible combinations on the travis-ci.org website.
If you are done run travis lint to make sure everything is okay. I myself found travis lint complaining about the experimental osx_image: keyword but omitting it, will make your build fail (as of this writing).
So and thats it. Select your repository in travis-ci and see how it runs (hopefully successful).
If you like, you can add
to your readme file on github too. Select the repo and click on the .
You will be presented with different import options (Image URL/Textile/Markdown etc). Copy the one you use and paste the code into your readme.