Stephane Simard
Stephane Simard

Reputation: 51

Azure DevOps Hosted Agents: How to build into a container, then extract the build artifacts

With Azure DevOps, when using the hosted agents, is there a way to build a project/solution into a container (Docker), then extract the build artifacts and publish them (not as an docker image).

Upvotes: 1

Views: 218

Answers (1)

4c74356b41
4c74356b41

Reputation: 72151

You could certainly do that, easiest way would be building with something like:

- script: |
    mkdir -p /docker-volume/npm
    cp -R $(Build.SourcesDirectory)/. /docker-volume/npm
    docker run -v /agent/npm:/npm node:10.15 bash \
      -c "cd /npm && npm ci && npm run web-build"
    exitcode=$?
    if [ $exitcode -ne 0 ]; then
      rm -rf /docker-volume/npm
      exit $exitcode
    fi
    cp -R /docker-volume/npm/build $(Build.SourcesDirectory)
    rm -rf /docker-volume/npm

basically launch a container and map a volume to the container. build stuff inside the container and push it to the volume, then grab the results from the volume and do what you need with them

Upvotes: 1

Related Questions