Hi circleci team!
I’m trying to have some steps of a job being conditionally executed depending on whether an entry exists in the cache or not. My idea was to use the recently added dynamic parameters.
Based on this thread, I tried the following:
my-job:
executor: my-executor
steps:
- initial_setup_step
- restore_cache:
keys:
- myCacheKey
name: Trying to restore cache
- run:
name: Check whether an entry was found in the cache
command: |
COMMAND_RESULT=$(some command here)
if [ -z "COMMAND_RESULT" ]; then
echo "export BUILD_NEEDED=\"true\"" >> $BASH_ENV
else
echo "export BUILD_NEEDED=\"false\"" >> $BASH_ENV
fi
- parameters:
build_needed:
type: string
default: "echo ${BUILD_NEEDED}"
- when:
condition:
equal: [ "true", << parameters.build_needed >> ]
steps:
- run:
name: Build
command: |
...
- other_step
...
The config checker complains:
Error calling job: 'my-job'
Arguments referenced without declared parameters: build_needed
Did I miss something obvious?
Thanks!
Rafael