2017-07-21 31 views
1

我有一個在linux系統上工作得很好的捲曲。我只是用一些參數遠程觸發Jenkins的工作。poweshell中的捲曲格式

但是Windows中的相同命令出錯了。

curl.exe -k --user abc:xyz -X POST https://myjenkins.com/job/abc/buildWithParameters??token=deploy\&release_version=2.3.1.0-5-auto2\&docker_registry=10.0.0.12:8083\&vcmts_build=vcmts_pi07 

以下是錯誤:

At line:1 char:260 
+ ... ??token=deploy\&release_version=2.3.1.0-5-auto2\&docker_registry=96.118.23.36:80 ... 
+     ~ 
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. 
At line:1 char:293 
+ ... .3.1.0-5-auto2\&docker_registry=10.0.0.12:8083\&vcmts_build=vcmts_pi07 
+     ~ 
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. 
At line:1 char:328 
+ ... 0.0.12:8083\&vcmts_build=vcmts_pi07 
+     ~ 
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

我假設用引號括住POST URL:'POST「https:... vcmts_pi07」'。如果失敗,請使用單引號:'POST'https:... vcmts_pi07''。 – gms0ulman

回答

1

將您的參數用單引號括起來,這些引號不像雙引號字符串那樣展開。

curl -k --user 'abc:xyz' -X POST 'https://myjenkins.com/job/abc/buildWithParameters?token=deploy&release_version=2.3.1.0-5-auto2&docker_registry=10.0.0.12:8083&vcmts_build=vcmts_pi07'