dockerazure-devopsazure-pipelines-release-pipelineazure-pipelines-build-taskelastic-container-registry

Pass a Built Docker Image from VSTS Build Pipeline to VSTS Release Pipeline


Pass Built Docker Image from Build Pipeline to Release Pipeline

I'm currently successfully building a Docker image in a VSTS Build Pipeline. I would like to take this built image and then Publish it as a Build Artifact so that a VSTS Release Pipeline may use our AWS credentials to push the image to our Elastic Container Registry.

Currently I'm finding a bunch of workarounds involving either one or the other -- a single Build pipeline that builds the image then pushes it to ECR via CLI, or a single Release Pipeline with Bash tasks to build the image and then an ECR task to push.

I've tried a bunch of different things, including publishing the directory that Ubuntu stores the Docker containers in (didn't work due to permissions). I'm trying to maintain a consistent paradigm in my company of Build Pipelines doing the building and Release Pipelines doing the deployment; it seems that trying not to mince these two ideas for an ECR release may not be plausible.

Is this possible, and if so how? Thanks!


Solution

  • example yaml build that is using service connection:

    jobs:
    - job: build_server
      timeoutInMinutes: 30 
      pool:
        vmImage: 'Ubuntu-16.04'
      steps:
      - checkout: self
        clean: true
    
      - task: Docker@1
        inputs:
          containerregistrytype: 'Container Registry'
          dockerRegistryEndpoint: yyy
          imageName: xxx
          includeLatestTag: true
          dockerFile: dockerfile
      - task: Docker@1
        inputs:
          containerregistrytype: 'Container Registry'
          dockerRegistryEndpoint: yyy
          imageName: xxx
          command: push