Am using the curl
command in PowerShell to post the comment in bit-bucket pull request page through a Jenkins job. I used the below PowerShell command to execute the curl
command, but am getting the error mentioned below. Could anyone please help me on this to get it worked?
$CurlArgument="-u [email protected]:yyyy -X POST https://xxx.bitbucket.org/1.0/repositories/abcd/efg/pull-requests/2229/comments --data content=success"
$CURLEXE='C:\Program Files\Git\mingw64\bin\curl.exe'
& $CURLEXE $CurlArgument
Error Details:
curl.exe : curl: no URL specified! At line:3 char:1 + & $CURLEXE $CurlArgument + ~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (curl: no URL specified!:String) [], RemoteException + FullyQualifiedErrorId : NativeCommandError curl: try 'curl --help' or 'curl --manual' for more information
This question is related to
powershell
curl
jenkins
In Powershell 3.0 and above there is both a Invoke-WebRequest and Invoke-RestMethod. Curl is actually an alias of Invoke-WebRequest in PoSH. I think using native Powershell would be much more appropriate than curl, but it's up to you :).
Invoke-WebRequest MSDN docs are here: https://technet.microsoft.com/en-us/library/hh849901.aspx?f=255&MSPPError=-2147217396
Invoke-RestMethod MSDN docs are here: https://technet.microsoft.com/en-us/library/hh849971.aspx?f=255&MSPPError=-2147217396
Use splatting.
$CurlArgument = '-u', '[email protected]:yyyy',
'-X', 'POST',
'https://xxx.bitbucket.org/1.0/repositories/abcd/efg/pull-requests/2229/comments',
'--data', 'content=success'
$CURLEXE = 'C:\Program Files\Git\mingw64\bin\curl.exe'
& $CURLEXE @CurlArgument
Source: Stackoverflow.com