Run CURL GET commands in Azure Pipeline Task

Viewed 8237

I am looking to run some CURL commands (GET mainly) in an Azure Pipeline Task to list/download some artifacts from a few sources. Would appreciate some help with any examples of how I can achieve this through a Pipeline Task using CURL, Powershell, Windows Command or any other appropriate method.

Thanks

2 Answers

The easiest way to do this is to use the Command Line task. For a YAML pipeline, this would look like

- task: CmdLine@2
  displayName: Curl Example
  inputs:
    script: 'curl google.com'

For a "Classic UI" pipeline, it would look like

enter image description here

Note that for either of these options you must be using a Linux build agent. If you are using a Windows build agent, you should use Invoke-WebRequest.

curl in PowerShell uses Invoke-WebRequest. From PowerShell 3.03.0 and above, we could use Invoke-WebRequest, which is equivalent to curl. You could refer to this doc for more details

Sample script in the power shell

 Invoke-WebRequest -URI https://www.educative.io/

In addition, in the Azure DevOps Artifacts, the URL contain special characters, we need use "" contain it. Such as

https://dev.azure.com/{Org name}/{project name}/_packaging?_a=feed+"&"+feed={feed name}
Related