I try to execute API call using when: on_fail
step
The idea is to rerun the build, but limit the number of retries.
So, looks like this
version: 2.1
parameters:
number_of_retries:
type: integer
default: 0
.....
- run:
name: On tests failed
command: |
if ((<< pipeline.parameters.number_of_retries >> < 3)); then
curl -X POST --header 'Accept: application/json' --header 'Content-Type: application/json' -d "{ \
\"parameters\": { \
\"number_of_retries\": $((<<pipeline.parameters.number_of_retries>> + 1)) \
} \
}" \
https://circleci.com/api/v2/workflow/${CIRCLE_WORKFLOW_ID}/rerun?circle-token=token_here
fi
when: on_fail
The problem is that number_of_retries
param is always 0 in each rerun
Why?