user1555190
user1555190

Reputation: 3243

Circleci passing a docker image in workflow jobs

Is it possible to pass docker images built in earlier job in circle ci

example

jobs:
    build:
         steps:
        - checkout
            // build image

    deploy:
         steps:
        - deploy earlier image

i cant see how i can access the image without rebuilding it

Upvotes: 0

Views: 477

Answers (2)

Abdirahman Mohamed
Abdirahman Mohamed

Reputation: 1

I believe you can achieve this by persisting the image to a workspace and then attaching the workspace when you want to deploy it. See CircleCI's workspace documentation here: https://circleci.com/docs/workspaces

Upvotes: 0

dnephin
dnephin

Reputation: 28080

Each job can run on a different host, so to share the image you would need to push it to a registry from the job that builds it.

To reference the same job that was pushed you'll need an identifier that is known ahead of time. A good example of this is the CIRCLE_SHA1 environment variable. You can use this variable as the image tag

jobs:
  build:
    machine: true
    steps:
      ...
      - run: |
          docker build -t repo/app:$CIRCLE_SHA1 .
          docker push repo/app:$CIRCLE_SHA1

  test:
    docker:
      - image: repo/app:$CIRCLE_SHA1
    steps:
      ...

Upvotes: 3

Related Questions