我在unix中执行curl工作正常。在Windows中同样的卷曲失败。
UNIX
curl -k --user admin:f1f82c270ec3ce28b4279809900fa00b -H "Jenkins-Crumb:3e7dc5a087ef7697f4a31d74fb99c4ac" -X POST https://jenkins-xyz/buildWithParameters?token=test\&release_version=2.1.0
在windows powershell中,同样的事情错误地跟随
PS D:\Softwares\curl> curl.exe -k --user admin:f1f82c270ec3ce28b4279809900fa00b -H "Jenkins-Crumb:3e7dc5a087ef7697f4a31d
74fb99c4ac" -X POST https://jenkins-xyz/buildWithParameters?token=test\&release_version=2.1.0
At line:1 char:226
+ ... ers?token=test\&release_version=2.1.0
+ ~
The ampersand (&) character is not allowed. The & operator is reserved for future use; wrap an ampersand in double
quotation marks ("&") to pass it as part of a string.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : AmpersandNotAllowed
答案 0 :(得分:0)
您需要引用您的参数或使用命令运算符(&
)和PowerShell的命令行。它将您的&符解释为命令运算符。
& .\curl.exe -k --user admin:f1f82c270ec3ce28b4279809900fa00b -H "Jenkins-Crumb:3e7dc5a087ef7697f4a31d74fb99c4ac" -X POST https://jenkins-xyz/buildWithParameters?token=test\&release_version=2.1.0