【问题标题】:Creating an event that triggers the pipeline when a ACR is updated with new image在使用新图像更新 ACR 时创建触发管道的事件
【发布时间】:2023-03-23 09:44:01
【问题描述】:

当使用最新图像自动更新 ACR 时,管道需要在 ADO 中触发,我该如何防止这种情况,或者有更好的方法来实现我想要的吗? 需要 ADO 管道的事件触发器

【问题讨论】:

  • 有一些疑问
  • - container: string # 容器资源的标识符,其实就是我们这里要呈现的,在这之前我们需要创建acr服务连接?
  • 请在下面的代码中提供示例值:example
  • 当我使用最新图像更新 acr 时,管道未触发

标签: azure-devops azure-pipelines azure-container-registry acr


【解决方案1】:

如果您需要使用容器映像作为 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

【讨论】:

  • 我在上面使用了带有标签的代码 latest ,仍然面临同样的问题,它没有触发
  • 你能试试具体的标签吗?
  • 您是否将触发器设置为trigger: tags: include: - production*
猜你喜欢
  • 2010-10-18
  • 1970-01-01
  • 2021-08-14
  • 2021-11-23
  • 2017-10-03
  • 1970-01-01
  • 2017-08-20
  • 2021-06-13
  • 1970-01-01
相关资源
最近更新 更多