Reputation: 81
I can't understand what YML does to my script and why everything reads as text. Can you please explain why everything is read as text and how to insert variables here?
script:
- >
curl --silent --show-error
--request POST
--header 'Content-Type: application/json'
--url "https:webhook"
--data '{"@type": "MessageCard","@context": "http://schema.org/extensions","themeColor": "0076D7","summary": "New changes ","sections": [{"activityTitle": "New changes","activitySubtitle": "Some Build","activityImage": "png","facts": [{"name": "Assigned to","value": "$GITLAB_USER_LOGIN"}, {"name": "Due date","value": "$CI_JOB_STARTED_AT"}, {"name": "Status","value": "$CI_JOB_STATUS"}],}]}'
The result is something like
Upvotes: 0
Views: 1172
Reputation: 352
It's because of difference between single and double quotes in bash - when you use single quotes the variables aren’t going to be expanded.
So, here is a workaround for the instance:
script:
- >
curl --silent --show-error
--request POST
--header 'Content-Type: application/json'
--url "https:webhook"
--data "'{"@type": "MessageCard","@context": "http://schema.org/extensions","themeColor": "0076D7","summary": "New changes ","sections": [{"activityTitle": "New changes","activitySubtitle": "Some Build","activityImage": "png","facts": [{"name": "Assigned to","value": "$GITLAB_USER_LOGIN"}, {"name": "Due date","value": "$CI_JOB_STARTED_AT"}, {"name": "Status","value": "$CI_JOB_STATUS"}],}]}'"
Upvotes: 2
Reputation: 686
Try with the triple funny quotes around the variables. Example: "'"$CI_JOB_STARTED_AT"'"
. A more cleaner way would be to move the curl command to a shell script.
Upvotes: 1