gpt4 book ai didi

docker - Docker推送任务中的Azure DevOps Pipeline引用当前标签

转载 作者:行者123 更新时间:2023-12-02 21:02:17 26 4
gpt4 key购买 nike

这是我的管道配置文件:

trigger:
- master

pool:
vmImage: 'Ubuntu-16.04'

variables:
imageName: 'pipelines-kotlin-docker'
service-connection: 'service-connection'

steps:
# Gradle
# Build using a Gradle wrapper script
- task: Gradle@2
inputs:
tasks: 'build' # A list of tasks separated by spaces, such as 'build test'

- task: Docker@2
displayName: Build an image
inputs:
repository: $(imageName)
command: build
Dockerfile: Dockerfile

- task: Docker@2
displayName: Push image
inputs:
containerRegistry: |
$(service-connection)
repository: $(imageName)
command: push
tags: |
test1
运行管道时,出现以下错误。

[error]tag does not exist: pipelines-kotlin-docker:test1


构建任务将产生以下输出: Successfully tagged pipelines-kotlin-docker:396我在推任务中用$(Build.BuildNumber)替换了test1,并收到以下错误。

[error]invalid reference format


如何在推送任务中引用由构建任务构建的图像标签?

最佳答案

Docker构建任务的默认标签是$(Build.BuildId)。检查here以获取有关Build变量的更多信息。

您应该在docker push任务中将tag:test1替换为$(Build.BuildId)。您在here中检查Docker任务参数。

- task: Docker@2
displayName: Push image
inputs:
containerRegistry: |
$(service-connection)
repository: $(imageName)
command: push
tags: |
$(Build.BuildId)

或者,您也可以指定标签:docker build task的test1。并保留标签:test1用于docker push任务。
- task: Docker@2
displayName: Build an image
inputs:
repository: $(imageName)
command: build
Dockerfile: Dockerfile
tags: |
test1

关于docker - Docker推送任务中的Azure DevOps Pipeline引用当前标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60040483/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com