简体   繁体   中英

Run CURL GET commands in Azure Pipeline Task

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

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

在此处输入图片说明

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}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM