对于多个环境,我需要有不同的 docker 镜像标记策略,即:开发和发布应该使用"最新"标签,而生产应该有正确的版本标签。
我目前正在为所有 AzureDevOps 构建管道使用单个 Yaml 文件,并希望将图像标记模式定义为每个构建的变量/让我们说称为 $(版本化)/。
构建步骤如下所示:
步骤- bash:docker push $(imageFullName):最新 显示名称:"码头工人推送"
那么有没有办法在这里有 IF 语句或其他条件操作。例如:
步骤- bash: docker push $(imageFullName):IF($(Versioned), $(Build.BuildNumber), latest) 显示名称:"码头工人推送"
你可以用这样的东西来做到这一点:
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')