azure-devops - 如何在azure devops构建yaml管道上有条件图像标签?

标签 azure-devops

对于几种环境,我需要有不同的docker镜像标记策略,即:开发和发布应该使用“最新”标签,而生产应该有正确的版本标签。

我目前正在为所有 AzureDevOps 构建管道使用单个 Yaml 文件,并且希望将图像标记模式定义为每个构建的变量/可以说称为 $(Versioned)/。

构建步骤如下所示:

steps
- bash: docker push $(imageFullName):latest
  displayName: 'docker push'

那么有没有办法在这里进行 IF 语句或其他条件操作。 例如:

steps
- bash: docker push $(imageFullName):IF($(Versioned), $(Build.BuildNumber), latest)
  displayName: 'docker push'

最佳答案

你也许可以用这样的东西来做到这一点:

steps
- bash: docker push $(imageFullName):latest
  displayName: 'docker push'
  condition: eq($(Versioned), 'true')
- bash: docker push $(imageFullName):$(Build.BuildNumber)
  displayName: 'docker push'
  condition: ne($(Versioned), 'true')

关于azure-devops - 如何在azure devops构建yaml管道上有条件图像标签?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54199340/

相关文章:

azure-devops - VSTS 构建定义 - 添加其他文件以构建输出

azure-devops - 如何在 Azure DevOps 中运行临时干净构建?

azure-devops - 如何使用 Visual Studio Online 和 .NET 桌面应用程序进行文件转换/变量替换

templates - Azure DevOps 管道 : same template twice in one stage

.net - VSTS 成功构建后,如何在电子邮件中发送代码覆盖率和测试(失败和通过)计数?

azure devops yaml管道未设置变量

git - 如何从 .gitignore 中列出的存储库中删除文件而不更改空格

azure - Visual Studio 在线构建和发布 - 将文件复制到另一个项目

azure - 在 Azure Pipelines 中缓存 node_modules 比安装它们需要更长的时间

azure-devops - 在 Azure Pipeline .NET Core CLI 任务中从 csproj 检索项目版本