Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to override Slack channels in Travis-CI notification when encrypting the token?

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

Overriding the channel is also possible, just add it to the configuration with a # separating them from account and token.

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

However, if I want to encrypt the credentials the way it is recommended:

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

will work just fine. But when I try:

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

I get a new encrypted token, but the notifications come on the default channel set up at integration time. What am I doing wrong?

Note: we use enterprise versions of everything (Slack, Travis, GitHub), in case this may play a role.

like image 597
mac Avatar asked Jun 25 '15 13:06

mac


2 Answers

The command isn't correct, it's missing the .rooms property at the end. It should be

travis encrypt "account:token#channel" --add notifications.slack.rooms
like image 152
Emerson Farrugia Avatar answered Oct 03 '22 06:10

Emerson Farrugia


the encrypt command is correct:

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

but the result inside the .travis.yml will be (wrong, and that's the problem):

notifications:
    slack: 
       secure: xxxxxxxxxxxxxxxxxxxxxx

you have to edit the .travis.yml manually after the encrypt command and add rooms, so correct is:

notifications:
  slack:
    rooms:
      secure: xxxxxxxxxxxxxx
like image 36
michabbb Avatar answered Oct 03 '22 06:10

michabbb