【发布时间】:2021-01-27 09:23:39
【问题描述】:
我在 Azure DevOps 中创建了一个管道,它构建了一个新容器,其中一个拉取请求被合并到 main 中。构建后,管道将新容器推送到我的 Azure 容器存储库中。目前的管道如下
trigger:
- main
resources:
- repo: self
variables:
# Container registry service connection established during pipeline creation
dockerRegistryServiceConnection: 'xxx'
imageRepository: 'shinyproxyimage'
containerRegistry: 'myrepo.azurecr.io'
dockerfilePath: '$(Build.SourcesDirectory)/DOCKERFILE'
tag: '$(Build.BuildId)'
# 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 and push an image to container registry
inputs:
command: buildAndPush
repository: $(imageRepository)
dockerfile: $(dockerfilePath)
containerRegistry: $(dockerRegistryServiceConnection)
tags: |
latest
之后我必须手动登录到 Azure 中的 Ubuntu 虚拟机并拉取新版本的容器。我将最后一行 tags 替换为单词 latest 以始终在此标签上保留最后一个版本。默认情况下,tags 的值来自 tag: '$(Build.BuildId)'。我做的对吗?
是否可以在没有我手动干预的情况下在管道中添加此步骤?
【问题讨论】:
-
是的,您正在寻找的是部署/发布过程。检查本指南并根据您的情况修改此内容docs.microsoft.com/en-us/azure/devops/pipelines/ecosystems/…
-
顺便说一句,托管 Docker 容器是您使用 VM 的唯一目的吗?如果是这样,您可能希望查看 PaaS 服务,例如 Azure 容器实例或容器应用服务
-
过程有点复杂。在 Azure DevOps 中,有 2 个管道用于 2 个服务(ShinyProxy 和 ShinyApp)。 ShinyProxy 是一个通用容器,可以连接到其他 ShinyApps。基本上,我正在寻找一种方法来在管道末端运行 bash 脚本到 Ubuntu 机器以拉取新版本的容器
-
关于这个问题的任何更新?它解决了你的问题吗?如果它适合你,请接受它。
-
我找到了自己的方式。我创建了一个完整的帖子来解释我做了什么puresourcecode.com/programming-languages/r/…