Azure-pipelines-tasks: Docker push no longer pushes *:latest tag with includeLatestTag: true

Created on 21 Sep 2018  路  13Comments  路  Source: microsoft/azure-pipelines-tasks

Environment

  • Server - VSTS

    • build number: 20180920.1
  • Agent - Hosted:

    • If using Hosted agent, provide agent queue name: Hosted Linux Preview

Issue Description

Could be related to #8031 ?

Over the last two days, it seems that includeLatestTag: true has silently stopped being respected in our docker push task because we no longer get the :latest container tag updated.

Checking the logs, it is clear that our builds no longer push to :latest and only push to :$(Build.BuildId) based on our configuration

No errors are shown

Release

Most helpful comment

Thanks for getting back to me. It would have been useful to provide communication or to fail builds that include includeLatestTag: true since we lost some time to people dev'ing against the out of date :latest containers

All 13 comments

our task looks like this

  - task: Docker@1
    displayName: "Push to the test ACR"
    inputs:
      azureSubscriptionEndpoint: xxx
      azureContainerRegistry: xxx
      command: "Push an image"
      imageName: "xxx/xxx:$(Build.BuildId)"
      includeLatestTag: true

@billytrend , We have removed "includeLatestTag" input from "Push an image" command to keep task consistency with 'docker push' command behavior. You can add another task to push latest tag image "xxx/xxx:latest" or you can change input from "xxx/xxx:$(Build.BuildId)" to "xxx/xxx" (image with no tag). If you specify image with no tag, docker push all versions/tags of image to repository.

Thanks for getting back to me. It would have been useful to provide communication or to fail builds that include includeLatestTag: true since we lost some time to people dev'ing against the out of date :latest containers

@billytrend , Sorry for inconvenience caused to you. We are updating the docs.

@vithati The tooltip on the "Include latest tag" checkbox for the "Build an image" command needs to be changed too. It shows:

Include the 'latest' tag when building or pushing the Docker image.

or you can change input from "xxx/xxx:$(Build.BuildId)" to "xxx/xxx" (image with no tag). If you specify image with no tag, docker push all versions/tags of image to repository.

This task builds the Docker image and creates 2 tags $BuildId and latest:
````

  • task: Docker@1
    displayName: 'Build an image'
    inputs:
    azureSubscriptionEndpoint: 'myServiceConnection'
    azureContainerRegistry: 'myContainerRegistry.azurecr.io'
    includeLatestTag: true
    command: 'build'
    ````

Trying to push both tags without a version information:
````

  • task: Docker@1
    displayName: 'Push the latest image'
    inputs:
    azureSubscriptionEndpoint: 'myServiceConnection'
    azureContainerRegistry: 'myContainerRegistry.azurecr.io'
    command: 'push'
    imageName: "$(Build.Repository.Name)"
    ````

This pushes only the image, tagged with the $BuildId :(

You can add another task to push latest tag image "xxx/xxx:latest"

When I try to follow this advice with the following tasks:
````

  • task: Docker@1
    displayName: 'Push the image'
    inputs:
    azureSubscriptionEndpoint: 'myServiceConnection'
    azureContainerRegistry: 'myContainerRegistry.azurecr.io'
    command: 'push'
  • task: Docker@1
    displayName: 'Push the latest image'
    inputs:
    azureSubscriptionEndpoint: 'myServiceConnection'
    azureContainerRegistry: 'myContainerRegistry.azurecr.io'
    command: 'push'
    imageName: "$(Build.Repository.Name):latest"
    The first push succeeds, but for the second I get an error like this:
    2019-01-11T13:04:43.8162105Z ##[debug]Arguments:
    2019-01-11T13:04:43.8162343Z ##[debug] push
    2019-01-11T13:04:43.8162503Z ##[debug] myContainerRegistry.azurecr.io/start.spring.io:latest
    2019-01-11T13:04:43.8162599Z [command]/usr/bin/docker push myContainerRegistry.azurecr.io/start.spring.io:latest
    2019-01-11T13:04:43.8162732Z The push refers to repository [myContainerRegistry.azurecr.io/start.spring.io]
    2019-01-11T13:04:43.8163414Z tag does not exist: myContainerRegistry.azurecr.io/start.spring.io:latest
    2019-01-11T13:04:43.8163932Z ##[debug]rc:1
    2019-01-11T13:04:43.8164108Z ##[debug]success:false
    2019-01-11T13:04:43.8224143Z ##[error]tag does not exist: myContainerRegistry.azurecr.io/start.spring.io:latest
    2019-01-11T13:04:43.8234089Z ##[debug]Processed: ##vso[task.issue type=error;]tag does not exist: myContainerRegistry.azurecr.io/start.spring.io:latest
    2019-01-11T13:04:43.8234407Z ##[debug]task result: Failed
    ````

The issue seems to be lower and upper-case issue. The docker build step reports the 2 tags to be created:
2019-01-11T13:04:37.2765515Z Successfully tagged myContainerRegistry.azurecr.io/start.spring.io:133 2019-01-11T13:04:37.2959758Z Successfully tagged mycontainerregistry.azurecr.io/start.spring.io:latest

The workaround is this:
````

  • task: Docker@1
    displayName: 'Build the image'
    inputs:
    azureSubscriptionEndpoint: 'myContainerRegistryRGServiceConnection'
    azureContainerRegistry: 'myContainerRegistry.azurecr.io'
    command: 'build'
  • task: Docker@1
    displayName: 'Build the latest image'
    inputs:
    azureSubscriptionEndpoint: 'myContainerRegistryRGServiceConnection'
    azureContainerRegistry: 'myContainerRegistry.azurecr.io'
    command: 'build'
    imageName: "$(Build.Repository.Name):latest"
  • task: Docker@1
    displayName: 'Push the image'
    inputs:
    azureSubscriptionEndpoint: 'myContainerRegistryRGServiceConnection'
    azureContainerRegistry: 'myContainerRegistry.azurecr.io'
    command: 'push'
  • task: Docker@1
    displayName: 'Push the latest image'
    inputs:
    azureSubscriptionEndpoint: 'myContainerRegistryRGServiceConnection'
    azureContainerRegistry: 'myContainerRegistry.azurecr.io'
    command: 'push'
    imageName: "$(Build.Repository.Name):latest"
    ````

That means I run the build and the push 2 times, once for each tag I want to get pushed to the ACR.

@mrumpf , You don't need to add duplicate tasks, change ACR name to lowercase 'myContainerRegistry.azurecr.io' to 'mycontainerregistry.azurecr.io' like below. It will work. I have opened https://github.com/Microsoft/azure-pipelines-tasks/issues/9369 to track container registry lower and upper-case name issue.

  • task: Docker@1
    displayName: 'Build an image'
    inputs:
    azureSubscriptionEndpoint: 'myServiceConnection'
    azureContainerRegistry: 'mycontainerregistry.azurecr.io'
    includeLatestTag: true
    command: 'build'

    • task: Docker@1

      displayName: 'Push the latest image'

      inputs:

      azureSubscriptionEndpoint: 'myServiceConnection'

      azureContainerRegistry: 'mycontainerregistry.azurecr.io'

      command: 'push'

      imageName: '$(Build.Repository.Name)'

Closing this issue. Please re-open issue if above workaround not working.

@vithati I followed your above suggestion -- however, the Push only pushed 'Latest' tag, not the versioned image.

Hi I am using below tasks in my azure pipeline and I am getting build no and latest tag.

- task: DockerCompose@0
  inputs:
    containerregistrytype: 'Azure Container Registry'
    azureSubscription: $(azureSubscription)
    azureContainerRegistry: $(azureContainerRegistry)
    dockerComposeFile: $(dockerComposefilePath)
    action: 'Build services'
    additionalImageTags: 'Build.BuildId'
- task: DockerCompose@0
  inputs:
    containerregistrytype: 'Azure Container Registry'
    azureSubscription: $(azureSubscription)
    azureContainerRegistry: $(azureContainerRegistry)
    dockerComposeFile: $(dockerComposefilePath)
    action: 'Push services'
Was this page helpful?
0 / 5 - 0 ratings