Reputation: 2877
I have a very simple pipeline for the tags. When I do the tag, I want to send simple slack webhook. My issue is that environment variable $BITBUCKET_TAG
is not rendered neither in echo
nor in slack message.
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"}'
and I get this in Slack
CoreLib tag [12:50 PM]
Tag $BITBUCKET_TAG has been created
What I want to achieve is to render the $BITBUCKET_TAG
value in my echo
and in Slack message properly, smth like:
CoreLib tag [12:50 PM]
Tag v2019.1.1 has been created
Upvotes: 7
Views: 15413
Reputation: 2877
Basic solution is super simple.
Instead of $BITBUCKET_TAG
should be '"$BITBUCKET_TAG"'
.
echo -d '{"username":"CoreLib tag","text":"Tag *'"$BITBUCKET_TAG"'* has been created"}'
Taken from here: https://superuser.com/questions/835587/how-to-include-environment-variable-in-bash-line-curl
Upvotes: 6