curl - How to send environment variables using curl
问题描述
I am trying to use slack to notify when a build is complete or if a build fails on GitlabCI. What I also wanna be able to do is append a predefined environment variable $GITLAB_CI_COMMIT_TITLE so along with the build notification I also know which build with what commit has completed/failed
In short,
This works
"curl -X POST -H 'Content-type: application/json' --data '{\"text\":\" Client Staging build complete. \n\"}'
https://hooks.slack.com/services/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"
But this doesnt
"curl -X POST -H 'Content-type: application/json' --data-binary '{
"'"$CI_COMMIT_TITLE"'" \n\"}'
The second command works, but it doesnt export the value of the variable, I just see '$CI_COMMIT_TITLE' in the slack notification.
What am I doing wrong? Any help will be greatly appreciated! Thank you!
解决方案
I stumbled across the same problem and it seems that the following solution works:
curl -X POST -H 'Content-type: application/json'
--data '{"text": " '"$CI_COMMIT_TITLE"' "}'
Hope it helps!
推荐阅读
- google-bigquery - 错误删除后恢复管理 Google 帐户
- flutter - 导航不适用于 Firebase 动态链接 - 使用颤振
- testng - Qmetry:测试用例执行的顺序没有按照 testNG 文件中的给定顺序发生
- python - 具有来自 Pandas 中 2 个不同列的颜色的散点矩阵(没有 seaborn)
- macos - Openflow 项目在 OMNET++ 5.6.2 中的 Mac OS 上构建失败
- microsoft-graph-api - Office 365:如何查找项目 ID 的最大长度
- javascript - 我想将大写单词转换为小写,将小写转换为大写,但我遇到了问题
- laravel - 没有获取数据透视表的 laravel id
- oracle - 用于学习的简单存储过程
- javascript - react-hook-form 在自定义选择框输入中不起作用