2

I have an azure devops pipeline.

    trigger:
- master

resources:
- repo: self

steps:
  - task: Docker@2
    displayName: Login to ACR
    inputs:
      command: login
      containerRegistry: myDockerHubConnection

  - task: Docker@2
    displayName: Build an image
    inputs:
        command: build
        arguments: --build-arg git_personal_token=ghp_MYTOKEN
        dockerfile: '$(Build.SourcesDirectory)/Dockerfile'
        tags: tag1

  - task: Docker@2
    displayName: Push image
    inputs:
        repository: 'crooksey201/ngx-int-api' #dockerhubAccountName/repoName
        command: push
        tags: tag1

This builds my image fine, but on the push stage, I get the error:

##[error]An image does not exist locally with the tag: ***/ngx-int-api

And in the list of docker images I just get:

REPOSITORY       TAG         IMAGE ID       CREATED                  SIZE
<none>           <none>      f705e0d37a95   Less than a second ago   1.76GB

This image has no tag which I am confused about, as I think I have specified the tags correctly in my pipeline, can anyone spot my error?

2 Answers 2

3

The issue was relating to the quotes around repository I updated a few things, but a working YAML is:

trigger:
- master

resources:
- repo: self

variables:
  tag: '$(Build.BuildId)'
steps:
  - task: Docker@2
    displayName: Login to ACR
    inputs:
      command: login
      containerRegistry: DockerHubConnectionName

  - task: Docker@2
    displayName: Build an image
    inputs:
        containerRegistry: DockerHubConnectionName
        repository: mydockerhubusername/my-repo
        command: build
        arguments: --build-arg git_personal_token=ghp_MYTOKEN
        dockerfile: '$(Build.SourcesDirectory)/Dockerfile'
        tags: |
          $(tag)
  - task: Docker@2
    displayName: push the image
    inputs:
        containerRegistry: DockerHubConnectionName
        repository: mydockerhubusername/my-repo
        command: push
        tags: |
          $(tag)
Sign up to request clarification or add additional context in comments.

Comments

0
+50

some of the inputs of the task Docker@2 in your example are not documented, and the imageName: might be repository:.

2 Comments

I updated my YAML file to remove deprecated decorators, even with the updates it shows no parsing errors and the output is the same.
I have awarded the bounty as I appreciate the time taken to look over this and refer to some deprecated inputs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.