-
系统:Ubuntu
-
具体问题:
项目组需要用到shell脚本来处理打包之后的后续动作,目前我已经通过Jenkins api拿到了构建结果,但是在发送给企微之后查看却没看到有构建结果展示,经排查发现是因为我上一步提取到的Jenkins构建结果的值没和发送请求的json字符串拼接到一起,麻烦懂行的大佬看下咋回事,以下是我自己拿来练习的代码
jenkins_result=`curl "http://172.19.121.108:4723/job/AndroidPackagebuild/28/api/json" | jq ".result"`
if [ $jenkins_result="SUCCESS" ]; then
json="{
\"msgtype\": \"text\",
\"text\": {
\"content\":
\"Jenkins打包结果展示,请相关同事注意。
构建编号:31
构建项目:Weixin
构建分支:master
构建版本:W23.1.1
构建结果: $jenkins_result
\",
\"mentioned_mobile_list\": ["@all"]}
}"
echo $json
curl -X "POST" -H "Content-Type: application/json" \
-d "$json" "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=558dad19-02f2-4481-8c63-6fff3cd4413b&debug=1"
fi
打印出来的参数如下: