【发布时间】:2021-06-11 07:36:32
【问题描述】:
我正在尝试在 azure devops bash 脚本任务中运行 curl 命令,我正在尝试从工件路径上传 jar。
在 curl 命令中给出静态文件路径时我能够成功运行它,但是我们如何动态传递文件路径?
curl -X POST \
https://anypoint.mulesoft.com/cloudhub/api/v2/applications \
-H 'authorization: bearer <your_token>' \
-H 'x-anypnt-env-id: <your_env_id>' \
-H 'x-anypnt-org-id: <your_org_id>' \
-F 'appInfoJson={
"domain": "<yourapplicationName>",
"muleVersion" : {"version":"3.9.1"},
"region" : "us-east-1",
"monitoringEnabled":true,
"monitoringAutoRestart" : true,
"workers": {"amount":1, "type": {"name":"Micro","weight":"0.1","cpu":"0.1 vCores", "memory":"500 MB memory"}},
"loggingNgEnabled":true,
"persistentQueues":false,
"properties":{
"key1":"value1"
}
}' \
-F autoStart=true \
-F file=@/path_to_the_file/yourapplication.jar
有没有办法动态地给出文件路径?我试图以这种方式提供-F file=@/path_to_the_file/**.jar,但** 未被接受。
【问题讨论】:
-
你能用你的文件名设置一个变量并将它传递给你的 curl 吗?
-
我试过 @Rakesh Gupta 它不接受 'variable =($ ls *.jar) echo $variable -F filepath=@"$variable" ' 语法对吗?
-
那么,您要附加多个文件吗?
-
没有我正在尝试单个文件,但该文件应该动态传递