1
votes

We are using YAML for our build definitions and I am looking for a way to run the every phase of the build in a Docker container. I don't want to create a VM in my premises and install the agent, I just want to create a Docker image and run my build inside of a container from that image on any Linux VM on VSTS.

Here's an example from the Gitlab approach:

image: monachus/hugo:v0.30.2
stages:
  - deploy
  - cert
before_script:
  - git submodule init
  - git submodule update --force
...

As you can see there's an image: section where you can specify where your build is gonna be running.

I've searched for this in the docs but can't find it. Does anyone knows if this feature exists in VSTS?

1

1 Answers

1
votes

I've found a solution using a preview feature, you can specify the image you want to use in a variable. Here's an example:

phases:
- phase: Java Build
  variables:
    _PREVIEW_VSTS_DOCKER_IMAGE: "maven:3.5-jdk-8"
  queue: Hosted Linux Preview
  steps:
  - bash: mvn clean verify
    displayName: Tests 

If I set the variable _PREVIEW_VSTS_DOCKER_IMAGE with a docker image, then that stage is going to run inside that Docker container.

There's some documentation on that here: https://github.com/Microsoft/vsts-agent/blob/master/docs/preview/runtaskindocker.md