Bitbucket 管道:echo 环境变量

Bitbucket pipelines: echo environment variable

我有一个非常简单的标签管道。当我做标签时,我想发送简单的 slack webhook。我的问题是环境变量 $BITBUCKET_TAG 既没有在 echo 中也没有在松弛消息中呈现。

pipelines:
  tags:
    '*':
    - step:
        script:
        - echo $BITBUCKET_TAG 
        - curl -X POST "https://hooks.slack.com/services/mysecuritykey" -H "Content-Type:application/json" -H "cache-control:no-cache" -d '{"username":"CoreLib tag","text":"Tag *$BITBUCKET_TAG* has been created"}'

我在 Slack 中得到了这个

CoreLib tag [12:50 PM]

Tag $BITBUCKET_TAG has been created

我想要实现的是在我的 echo 和 Slack 消息中正确呈现 $BITBUCKET_TAG 值,如下所示:

CoreLib tag [12:50 PM]

Tag v2019.1.1 has been created

基本解决方案超级简单。

而不是 $BITBUCKET_TAG 应该是 '"$BITBUCKET_TAG"'

E.g. -d '{"username":"CoreLib tag","text":"Tag *'"$BITBUCKET_TAG"'* has been created"}'

摘自此处: https://superuser.com/questions/835587/how-to-include-environment-variable-in-bash-line-curl