3
votes

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!

1
just create a service connection to ecr of a docker type and use it in docker push step?4c74356b41
As I understand it, Service Connections are only available for use in Release Pipelines, which I would like to receive a built Docker image from a Build Pipeline then use the Service Connection to push to ECR.BrandonCookeDev
no, they are available in both build and release pipelines4c74356b41
It would still be preferable to me to split the paradigms of Building the docker image in a Build Pipeline and Pushing to ECR in a Release Pipeline. To me it makes the most sense to have those responsibilities distributed. Is that doable at this time?BrandonCookeDev
thats exactly what is happening in my example. that build is only building the image. release will push it somewhere4c74356b41

1 Answers

-1
votes

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