Skip to content

Instantly share code, notes, and snippets.

@cwoolum
Last active December 3, 2018 19:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cwoolum/ab6ba4f3f3f50ef74a41a550a9642969 to your computer and use it in GitHub Desktop.
Save cwoolum/ab6ba4f3f3f50ef74a41a550a9642969 to your computer and use it in GitHub Desktop.
YAML builds in Azure Pipelines
parameters:
services: []
jobs:
- job: Build
pool:
name: Hosted Ubuntu 1604
steps:
- task: Docker@1
displayName: 'Login to the ACR'
inputs:
azureSubscriptionEndpoint: 'some-random-guid'
azureContainerRegistry: 'myazuredevopsinstance.azurecr.io'
command: login
- ${{ each service in parameters.services }}:
- bash: |
docker pull ${{ service.tagName }}:builder || true
docker build --target build --cache-from ${{ service.tagName }}:builder -f ${{ service.dockerfileName }} -t ${{ service.tagName }}:builder --build-arg PAT=$TOKEN .
docker pull ${{ service.tagName }}:latest || true
docker build --cache-from ${{ service.tagName }}:builder --cache-from ${{ service.tagName }}:latest -f ${{ service.dockerfileName }} -t ${{ service.tagName }}:${{ service.version }} -t ${{ service.tagName }}:latest --build-arg PAT=$TOKEN .
docker push ${{ service.tagName }}:builder
docker push ${{ service.tagName }}:${{ service.version }}
docker push ${{ service.tagName }}:latest
displayName: 'Build, tag and push image'
failOnStderr: true
env:
TOKEN: $(system.accesstoken)
- task: CopyFiles@2
displayName: 'Copy Files to: $(Build.ArtifactStagingDirectory)'
inputs:
Contents: '**/charts/**/*'
TargetFolder: '$(Build.ArtifactStagingDirectory)'
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: charts'
inputs:
ArtifactName: charts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment