运行 power shell 脚本
curl -X POST --data-urlencode 'payload={"channel": "#personal", "username": "Jenkins", "text": "Building $env:BUILD_NUMBER", "icon_emoji": ":computer:"}' https://xxxxxx.slack.com/services/hooks/incoming-webhook?token=aseaUO
或者
curl -X POST --data-urlencode 'payload={"channel": "#personal-notification", "username": "Jenkins", "text": "Building ${BUILD_NUMBER}", "icon_emoji": ":computer:"}' https://xxxxxx.slack.com/services/hooks/incoming-webhook?token=aseaUO
{BUILD_NUMBER} 没有被 curl 有效负载中的实际内部版本号替换
--Edit 我注意到我的 sh 脚本正在调用 git\bin\sh.exe。那是问题吗?
在尝试以下评论之一 curl -X POST --data-urlencode $('payload={0}"channel": "#personal", "username": "Jenkins", "text": "Building {1} ", "icon_emoji": ":computer:"{2}' -f "{", $env:rohan) "}" https://xxxxxx.slack.com/services/hooks/incoming-webhook?token=aseaUO我明白了
在直接尝试在 PS 终端上运行脚本时,我得到