- run:
name: notify on slack channel
command: |
sudo apt-get install curl |
curl -X POST -H 'Content-type: application/json' \
--data '{"text":"${ECS_SERVICE_NAME} deployed to staging with revision ${CIRCLE_SHA1}"}' \
https://hooks.slack.com/services/****
ECS_SERVICE_NAME and CIRCLE_SHA1 are variables defined.
But when I run this I get it literally and not the values.
What’s the correct way to achieve this?
Henna
October 7, 2020, 7:23pm
2
Hi @sudipbhandari126 ,
It looks like you curl request is using single quotes for the parameter.
In bash single quotes are used to preserve the literal value of each character inside the string. To fix this, change the single quotes to double quotes, and escape the double quotes inside the string, like in the example below.
You can find more information on quoting characters in bash here: http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_03_03.html
--data "{\"text\":{\"${ECS_SERVICE_NAME} deployed to staging with revision ${CIRCLE_SHA}\"}}"
2 Likes
Thanks a lot. It worked!!
I think it’s time to really learn some bash
system
Closed
October 18, 2020, 5:37am
4
This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.