I am building and pushing Docker images to my Azure Container Registry from Azure DevOps using the azure-pipelines.yml
file below.
This works great except that there doesn't seem to be any relation created between the created image and the pipeline that created it. There is no artifacts listed on the executed pipeline:
The artifact is created correctly such that I can use it when running a release pipeline and if I inspect the image locally I can confirm that it has the labels on it created by the Docker task as described here.
# Docker
# Build and push an image to Azure Container Registry
# https://docs.microsoft.com/azure/devops/pipelines/languages/docker
trigger:
- none
resources:
- repo: self
variables:
# Container registry service connection established during pipeline creation
dockerRegistryServiceConnection: '<my connection>'
imageRepository: '<my repo>'
containerRegistry: '<my registry>'
dockerfilePath: '$(Build.SourcesDirectory)/Dockerfile'
tag: '$(Build.BuildNumber)'
DOCKER_BUILDKIT: 1
# Agent VM image name
vmImageName: 'ubuntu-latest'
stages:
- stage: Build
displayName: Build and push stage
jobs:
- job: Build
displayName: Build
pool:
vmImage: $(vmImageName)
steps:
- task: Docker@2
displayName: Build
inputs:
command: build
repository: $(imageRepository)
dockerfile: $(dockerfilePath)
arguments: '--target prod'
containerRegistry: $(dockerRegistryServiceConnection)
tags: |
latest
$(tag)
- task: Docker@2
displayName: Push
inputs:
command: push
repository: $(imageRepository)
dockerfile: $(dockerfilePath)
containerRegistry: $(dockerRegistryServiceConnection)
tags: |
latest
$(tag)