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
[fusion_builder_container hundred_percent=“yes“ overflow=“visible“][fusion_builder_row][fusion_builder_column type=“1_1″ background_position=“left top“ background_color=““ border_size=““ border_color=““ border_style=“solid“ spacing=“yes“ background_image=““ background_repeat=“no-repeat“ padding=““ margin_top=“0px“ margin_bottom=“0px“ class=““ id=““ animation_type=““ animation_speed=“0.3″ animation_direction=“left“ hide_on_mobile=“no“ center_content=“no“ min_height=“none“]
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 [fusion_imageframe lightbox=“no“ lightbox_image=““ style_type=“none“ bordercolor=““ bordersize=“0px“ borderradius=“0″ stylecolor=““ align=“none“ link=““ linktarget=“_self“ animation_type=“0″ animation_direction=“down“ animation_speed=“0.1″ class=““ id=““][/fusion_imageframe]
to your readme file on github too. Select the repo and click on the [fusion_imageframe lightbox=“no“ lightbox_image=““ style_type=“none“ bordercolor=““ bordersize=“0px“ borderradius=“0″ stylecolor=““ align=“none“ link=““ linktarget=“_self“ animation_type=“0″ animation_direction=“down“ animation_speed=“0.1″ class=““ id=““][/fusion_imageframe].
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.