我正在尝试执行curl命令,以获取来自circleci的apk路径
curl -u $CIRCLE_API_KEY: https://circleci.com/api/v1.1/project/github /<username>/<projectname>/latest/artifacts?branch=develop | grep -o 'https://[^"]*' > artifacts.txt
它返回
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 1229 100 1229 0 0 2063 0 --:--:-- --:--:-- --:--:-- 2065
它工作得很好,而且像apk这样的网址即https://123-67792073-gh.circle-artifacts.com/0/apks/。来到artifacts.txt
但是,如果我添加&#34;&amp; filter = success&#34;在curl url的末尾,它不会写入artifacts.txt并且不会退出命令。
curl -u $CIRCLE_API_KEY: https://circleci.com/api/v1.1/project/github/<username>/<projectname>/latest/artifacts?branch=develop&filter=success | grep -o 'https://[^"]*' > artifacts.txt
返回
[1] 43348
arsinha$ [ {
"path" : "apks/<apkname>.apk",
"pretty_path" : "apks/<apkname>.apk",
"node_index" : 0,
"url" : "https://123-67792073-gh.circle-artifacts.com /0/apks/<apkname>.apk"
},]
它不会退出,因为我必须单击Ctrl + C才能退出。任何原因导致卷曲网址附加&#34;&amp; filter = success&#34;
答案 0 :(得分:0)
您需要将URL包装在引号中以阻止shell将&
解释为将命令放入后台的请求。
e.g。
curl -u $CIRCLE_API_KEY: "https://circleci.com/api/v1.1/project/github/<username>/<projectname>/latest/artifacts?branch=develop&filter=success" | grep -o 'https://[^"]*' > artifacts.txt