2

By default, the Hosted Agent I'm working with is not supporting yarn command but only npm. Sad, right?

Of course, I could have a step in my build pipeline that downloads and installs yarn via scoop or choco[latey] on each run, but I really don't like the idea of the build increase time for something that should be available to me out of the box.

So how do I preinstall the tools I need upfront?

Daniel Mann
  • 57,011
  • 13
  • 100
  • 120
Igor Soloydenko
  • 11,067
  • 11
  • 47
  • 90
  • Related to https://stackoverflow.com/questions/55271108/azure-devops-how-do-i-run-an-arbitrary-test-command-on-a-hosted-agent – Igor Soloydenko Mar 20 '19 at 22:33
  • The tools installed on the hosted images is documented [here](https://github.com/Microsoft/azure-pipelines-image-generation). From what I can tell both the VS2017 and Ubuntu16.04 images both currently have Yarn 1.13.0. – Matt Mar 21 '19 at 14:01

3 Answers3

2

You do not necessarily need to use a private agent -- you can run your builds in a prebuilt container. This way you can have control over a hosted agent.

resources:
  containers:
  - container: tests
    image: my/container:tests

jobs:
  - job: run_tests
    container: tests
    pool:
      vmImage: 'Ubuntu-16.04'
    steps:
    # actual build
    ...
oalders
  • 5,239
  • 2
  • 23
  • 34
4c74356b41
  • 69,186
  • 6
  • 100
  • 141
0

Of course, I could have a step in my build pipeline that downloads and installs yarn via scoop or choco[latey] on each run, but I really don't like the idea of the build increase time for something that should be available to me out of the box.

This is the correct approach to install something on a build agent. If the increased time is a problem for you you could consider installing an agent on a machine of yours. But even if you use a private agent the approach to have some the installation done as a step of a build would be the correct approach

D.J.
  • 3,644
  • 2
  • 15
  • 22
  • "to have some the installation done as a step of a build would be the correct approach" is very arguable at best. If I want to have `yarn` command available I need to run `scoop` or `choco` command to install it. Neither of those tools is available either, so I need to install them too. I may or may not want to orchestrate my tools as a part of the pipeline -- that's totally a preference thing. And I personally would prefer the toolset to be described side by side with the pipeline definition but NOT INSIDE it. – Igor Soloydenko Mar 20 '19 at 23:13
  • 2
    Just a small detail: choco is available on the hosted agents. – Wouter de Kort Mar 20 '19 at 23:38
  • 3
    @IgorSoloydenko hosted vs2017 has choco as well as yarn installed – D.J. Mar 20 '19 at 23:56
  • @D.J. I'll try them out. Thanks! – Igor Soloydenko Mar 21 '19 at 00:08
-1

You don't. The hosted agent is fresh every time. There is nothing you can do to cache things on it.

If that's a requirement, you should install a private agent on a machine you control.

Daniel Mann
  • 57,011
  • 13
  • 100
  • 120