How to redefine Slack channels in Travis-CI notification when token encryption?

The online documentation for Travis-CI notification on Slack says:

It is also possible to redefine the channel, just add it to the C # configuration, separating them from the account and token.

notifications: slack: '<account>:<token>#development' 

However, if I want to encrypt my credentials as recommended:

 travis encrypt "<account>:<token>" --add notifications.slack 

will work fine. But when I try:

 travis encrypt "<account>:<token>#development" --add notifications.slack 

I get a new encrypted token, but notifications come through the default channel set during integration. What am I doing wrong?

Note. We use corporate versions of everything (Slack, Travis, GitHub) if this can play a role.

+5
source share
3 answers

The command does not match ; it does not have the .rooms property at the end. It should be

 travis encrypt "account:token#channel" --add notifications.slack.rooms 
+5
source

encryption command is correct:

 travis encrypt "account:token#channel" --add notifications.slack 

but the result inside .travis.yml will be (incorrect, and what a problem):

 notifications: slack: secure: xxxxxxxxxxxxxxxxxxxxxx 

you need to edit .travis.yml manually after the encryption command and add rooms , so that is correct:

 notifications: slack: rooms: secure: xxxxxxxxxxxxxx 
+2
source

You need to run the following encryption command for each slack channel that you want to include in notifications. Make sure you keep a copy of each secure encrypted message , as the command will overwrite your travis.yml every time it starts.

 travis encrypt "account:token#channel1" --add notifications.slack.rooms travis encrypt "account:token#channel2" --add notifications.slack.rooms 

Finally, add markers for each channel in the following format:

 notifications: slack: rooms: - secure: secure_token_for_channel1 - secure: secure_token_for_channel2 
+1
source

All Articles