Reputation: 9072
I'm new to CircleCI workflows and I would like to create a workflow with two steps.
version: 2
jobs:
build:
docker:
- image: docker.repo.ch/image:${TAG}
Is there some mechanism to hand over a value as a paramter from one build job to another one in within a CircleCI workflow?
Upvotes: 1
Views: 436
Reputation: 5612
Since every run step is a new shell, environment variables are not shared across steps. If you need an environment variable to be accessible in more than one step, export the value using BASH_ENV.
https://circleci.com/docs/2.0/env-vars/#setting-an-environment-variable-in-a-step
workflows:
version: 2
pass_tag:
jobs:
- create_tag
- use_tag:
requires:
- create_tag
executors:
node:
docker:
- image: circleci/node:4.8.2
jobs:
create_tag:
executor: node
steps:
- run: echo "export MY_TAG=$CIRCLE_SHA1" >> $BASH_ENV
use_tag:
executor: node
steps:
- run: echo $MY_TAG
use CircleCI orbs
(like a library) to build and push the image:
version: 2.1
orbs:
aws-ecr: circleci/[email protected]
workflows:
version: 2
example:
jobs:
- aws-ecr/build-and-push-image:
account-url: DEV_AWS_ECR_ACCOUNT_URL
aws-access-key-id: DEV_ACCESS_KEY_ID
aws-secret-access-key: DEV_SECRET_ACCESS_KEY
create-repo: true
repo: '${CIRCLE_PROJECT_REPONAME}'
region: AWS_DEFAULT_REGION
tag: '${CIRCLE_SHA1}'
- pull_image:
requires:
- aws-ecr/build-and-push-image
jobs:
pull_image:
*** pull and use your image here ***
Upvotes: 4