问题描述
当使用最新图像更新 ACR 时,需要在 ADO 中自动触发管道,如何防止这种情况发生,或者是否有更好的方法来实现我想要的? 需要 ADO 管道的事件触发器
解决方法
如果您需要使用容器映像作为 CI/CD 管道的一部分,您可以使用 Resources: containers
来实现。容器资源可以是公共或私有 Docker Registry 或 Azure Container Registry。
resources: # types: pipelines | repositories | containers | builds | packages
containers:
- container: string # identifier for the container resource
type: string # type of the registry like ACR,GCR etc.
azureSubscription: string # Azure subscription (ARM service connection) for container registry;
resourceGroup: string # resource group for your ACR
registry: string # registry for container images
repository: string # name of the container image repository in ACR
trigger: # Triggers are not enabled by default and need to be set explicitly
tags:
include: [ string ] # image tags to consider the trigger events,optional; defaults to any new tag
exclude: [ string ] # image tags on discard the trigger events,optional; defaults to none
例如:
resources:
containers:
- container: petStore
type: ACR
azureSubscription: ContosoARMConnection
resourceGroup: ContosoGroup
registry: petStoreRegistry
repository: myPets
trigger:
tags:
include:
- production*
或
resources:
containers:
- container: mycontainer # name of the container (Alias)
type: ACR # type of registry
azureSubscription: arm-connection # name of the ARM service connection
resourceGroup: rg-storage-eastus # Azure resource group with the container
registry: mycontainerregistry # Azure container registry name
repository: hello-world # name of the of container image collection
trigger:
tags:
- latest # tag for the container image to use