0

I'm trying to send a slack notification using the .gitlab-ci.yml and I need to pass the Commit's message in the message like this: "The version ${CI_COMMIT_TAG} Version is available!"

But i'm still not able to get the environment variable desired when receiving the notification on my channel and passing it like this in the file:

script: 
    - "curl -X POST -H 'Content-type: application/json' --data '{\"text\":\"The version ${CI_COMMIT_TAG} version is available!\"} ' https://hooks.slack.com/services/....../......"

Do you have any clues ? I'm not used to Curl and Yaml

Thanks and Have a good day!

Clément
  • 131
  • 1
  • 10

1 Answers1

1

--data '...'

Variable expansion in bash does not work within single quotes. Use double quotes instead.

Alternatively, use a data file to avoid formatting JSON inline:

curl -d "@data.json" ...
sytech
  • 29,298
  • 3
  • 45
  • 86