【问题标题】:How to override Slack channels in Travis-CI notification when encrypting the token?加密令牌时如何覆盖 Travis-CI 通知中的 Slack 通道?
【发布时间】:2015-06-25 13:42:51
【问题描述】:

Slack 上 Travis-CI 通知的在线文档说:

也可以覆盖通道,只需将其添加到配置中,用 # 将它们与帐户和令牌分开即可。

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

但是,如果我想按照推荐的方式加密凭据:

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

可以正常工作。但是当我尝试时:

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

我获得了一个新的加密令牌,但通知来自集成时设置的默认频道。我做错了什么?

注意:我们使用所有东西的企业版本(Slack、Travis、GitHub),以防这可能发挥作用。

【问题讨论】:

    标签: travis-ci slack-api


    【解决方案1】:

    命令不正确,它最后缺少.rooms 属性。应该是

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

    【讨论】:

      【解决方案2】:

      加密命令正确:

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

      但 .travis.yml 中的结果将是(错误的,这就是问题所在):

      notifications:
          slack: 
             secure: xxxxxxxxxxxxxxxxxxxxxx
      

      您必须在加密命令之后手动编辑 .travis.yml 并添加房间,所以正确的是:

      notifications:
        slack:
          rooms:
            secure: xxxxxxxxxxxxxx
      

      【讨论】:

        【解决方案3】:

        您需要为要包含在通知中的每个松弛通道运行以下加密命令。 确保您保留每条安全加密消息的副本,因为该命令每次运行时都会覆盖您的 travis.yml

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

        最后按以下格式为每个频道添加令牌:

        notifications:
          slack:
            rooms:
              - secure: secure_token_for_channel1
              - secure: secure_token_for_channel2
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2017-03-08
          • 1970-01-01
          • 1970-01-01
          • 2017-10-27
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2021-06-26
          相关资源
          最近更新 更多