How to enable the cURL capability

Problem:

I want to use the cURL task in VSO build but when I try I get the following error:

There are issues with the request or definition that may prevent the
build from running:
No agent could be found with the following capabilities: npm, curl
Queue the build anyway?

Solution:

Stand up your own agent and install cURL yourself.

Explanation:

The hosted build agents provided by VSO Build do not have the ability or, in VSO build terms, the capability to run all of the tasks we provide out of the box.  Each task has the option to define demands. Demands are capabilities that must exist on an agent before that task can be executed.  When you add the cURL task to your build definition, it also adds a curl demand.  If you review the capabilities of the hosted build agents, you will notice that curl is not listed. Therefore, if you attempt to queue a build against our hosted build agents, you will get an error.

The solution is to simply stand up your own agent and install the needed tools.  You can learn how to download and configure an agent here.  The agent can be installed on any machine that can reach VSO.

Installing cURL is not as easy as it should be; if you use Chocolatey, life is much easier.  But before you can use Chocolatey to install cURL, you have to install Chocolatey.  Luckily, installing Chocolatey is very easy.  Simply copy and paste the string below into an administrative command prompt.

@powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))" && SET PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin

Once that command completes, you can simply type the following command to install cURL:

choco install curl

Unfortunately, that is not enough.  At this point, we have cURL on the machine but our agent is still unaware that it has this new capability.  We need to register the capability on the agent.  You can read how to do that in my blog post here.  Just ensure the capability is registered to match the demand in the error message. In this example with cURL, the capability is curl.

Once the capability is registered, restart your agent. If you are running your agent in interactive mode, I suggest you close and reopen a new command prompt.  If you are running as a service, simply restarting the service will work.

Comments (3) -

  • David Parvin

    2/13/2017 3:27:14 AM | Reply

    Woohoo, I was able to get my agent called to use cURL on my machine and not the hosted one.  I had to start a new build instead of retrying to deploy a previous release.  Now my cURL is giving the error that it can't access the folder where my items are that cURL is supposed to copy to my ftp site.

    • David Parvin

      2/14/2017 5:56:06 AM | Reply

      I guess it helps to know that cURL does not work well with wildcard paths.  I works ok for uploading a list of files to the same place.  I have not yet figured out how I can tell it to upload a set of files and folders and it takes care of all of it.

  • Kunj Bihari

    3/10/2017 5:07:37 PM | Reply

    I have configured everything as explained above. While running Apache tomcat deploy job in VSTS, I am getting the below error.  Any suggestion?

    2017-03-10T16:50:29.7156451Z ##[section]Starting: Deploy application to a Tomcat server
    2017-03-10T16:50:29.8367332Z ==============================================================================
    2017-03-10T16:50:29.8367332Z Task         : Deploy to Apache Tomcat
    2017-03-10T16:50:29.8367332Z Description  : Deploy application to a Tomcat server.
    2017-03-10T16:50:29.8367332Z Version      : 0.1.3
    2017-03-10T16:50:29.8367332Z Author       : Microsoft Corporation
    2017-03-10T16:50:29.8367332Z Help         : [More Information](http://aka.ms/tomcatdeploymenttask)
    2017-03-10T16:50:29.8367332Z ==============================================================================
    2017-03-10T16:50:30.8652743Z [command]C:\ProgramData\chocolatey\bin\curl.exe --stderr - --fail -o C:\Users\KUNJ\AppData\Local\Temp\tomcatResponse_1489164630848.txt -u tomcat:tomcat -T C:\agent\_work\r1\a\MavenHelloWorld_Build\drop\MavenHelloWorld\target\MavenHelloWorld.war http://192.168.1.5:8080/manager/text/deploy?path=/MavenHelloWorld&update=true
    2017-03-10T16:50:31.8707251Z   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
    2017-03-10T16:50:31.8737269Z                                  Dload  Upload   Total   Spent    Left  Speed
    2017-03-10T16:50:31.8797309Z
    2017-03-10T16:50:31.8797309Z   0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
    2017-03-10T16:50:32.1909390Z   0  2180    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
    2017-03-10T16:50:32.1919399Z 100  2180    0     0  100  2180      0   1810  0:00:01  0:00:01 --:--:--  1810
    2017-03-10T16:50:32.1919399Z curl: (22) The requested URL returned error: 403 Forbidden
    2017-03-10T16:50:32.2209585Z ##[error]Error: C:\ProgramData\chocolatey\bin\curl.exe failed with return code: 22
    2017-03-10T16:50:32.2209585Z Return code: 1
    2017-03-10T16:50:32.2279629Z ##[section]Finishing: Deploy application to a Tomcat server

    --->> I have configured 'Tomcat Server URL' in  VSTS job.
    Tomcat Server URL -- http://192.168.1.5:8080

    -->> I have also added the 'curl' capability in VSTS private agent.
    curl -- C:\ProgramData\chocolatey\lib\curl\bin

    Thanks in Advance.

Add comment

Loading