将图像从 azure devops 多阶段管道发布到 DockerHub

Publish image from azure devops multi-stage pipeline to DockerHub

我正在尝试在 Azure DevOps 中设置一个 Multi Stage Pipeline。在我需要将图像发布到我的 DockerHub 帐户之前,它运行良好。这是我的 YAML:

的片段

我必须承认,我明白为什么,我的凭据无处可去 :) 我尝试使用 Environments 进行设置,但我可以添加的唯一资源是 Kubernetes(不确定为什么会这样)

关于如何使用 DockerHub 设置身份验证有什么建议吗?

您可以使用 docker login 步骤:

- task: Docker@2
  inputs:
    command: login
    containerRegistry: service_connection_name

您应该将此步骤放在实际用于推送图像的步骤之前

关于如何创建连接的文档:https://docs.microsoft.com/en-us/azure/devops/pipelines/library/service-endpoints?view=azure-devops&tabs=yaml#sep-docreg