hi
I am new to circle ci yml configs and i am using context as below but when i run the pipeline the context varaibles are not available for the pilepline.
Any inputs will be much appreciated
version: 2.1
defaults: &defaults
efg: “4.3.0”
dev-env: &dev-env
<<: *defaults
executors:
mulesoft-executor:
working_directory: /tmp/workspace
docker:
- image: ‘circleci/openjdk:8-jdk’
deploy-base: &deploy-base
steps:
- attach_workspace:
at: /tmp/workspace
- run:
name: Install
command: |
mvn install -s settings.xml -Dabc = $abc
dev-deploy:
<<: *deploy-base
executor: mulesoft-executor
environment:
<<: *dev-env
workflows:
build-deploy:
jobs:
- dev-deploy::
context:
- abc
Can you repost your config.yml file with the whitespace retained - the </> option in the icon bar of the text input box.
As the config.yml is just yaml the whitespace is key to understanding what is going on when an error occurs.
One issue that stands out is that you have misordered your dev-deploy section as currently you are trying to create an order of steps, executor and then environment values. The steps should be after the executor and environment values.
thanks for the looking at it.
is it visible now>?
OK, I’ve moved things around but you can see my version below which runs.
Key things to note
- You missed out the job: line needed when you start to define jobs
- You miss-ordered the definition of your dev-deploy: job
- You miss-indented your use of <<: *dev-env
Rather than use anchors to define reusable commands you should look up CircleCI’s command feature that allows you to define reusable code as reusable functions. These can then just be used as user-defined steps and support the passing of parameters.
version: 2.1
executors:
mulesoft-executor:
working_directory: /tmp/workspace
docker:
- image: circleci/openjdk:8-jdk
defaults: &defaults
efg: “4.3.0”
dev-env: &dev-env
<<: *defaults
deploy-base: &deploy-base
steps:
- attach_workspace:
at: /tmp/workspace
- run:
name: Install
command: |
mvn install -s settings.xml -Dabc = "testvalue"
jobs:
dev-deploy:
executor: mulesoft-executor
environment:
<<: *dev-env
<<: *deploy-base
workflows:
build-deploy:
jobs:
- dev-deploy
# context:
# - abc
I made these changes and i am still able to see the context variables set in the “Preparing environment variables” stage of the pipeline.
i defined the abc context variable but i am not able to use it at run time
workflows:
build-deploy:
jobs:
- dev-deploy
# context:
# - abc
As I did not have the context defined I commented out the lines - a # indicates a comment.
thanks may i know if there is a way to find why the context variables are not loaded at runtime
The only real debug tool available to us end users is echo commands within run steps and a lot of R&D.
If you are currently using my example code, note that I hard coded the variable on the mvn line.