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
The conclusion is that if you need to use the curl (as same as in the Windows command prompt) in PowerShell then you need to call the curl executable( curl.exe ) directly. Else, you should stick to the PowerShell curl alias which resolves to the Invoke-WebRequest cmdlet under the hood.
curl requires minimal user interaction and is therefore preferred for automation. curl in PowerShell uses Invoke-WebRequest . From PowerShell 3.0 and above, you can use Invoke-WebRequest , which is equivalent to curl .
cURL comes natively installed on Unix based operating systems such as MacOS and Linux. But windows is left out. Now that we have PowerShell on windows, you can get some of the functionality of cURL using various cmdlets like invoke-webrequest.
crt . Invoke curl.exe from a command window (in Windows, click Start > Run and then enter "cmd" in the Run dialog box). You can enter curl --help to see a list of cURL commands.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With