I am using the Cypress orb and I want to set a boolean field to either true or false based off an Environment variable inside my CircleCI config.yml.
In the CircleCI UI I have configured an Environment variable called $CYPRESS_RECORD
and set it to a value of true.
The record field takes a value of type boolean and so my configuration is throwing the following error:
Type error for argument record: expected type: boolean, actual value: “$CYPRESS_RECORD” (type string)
I have tried wrapping it in << >> tags and doing some kind of equality checks and it always throws either an invalid syntax error or the incorrect type error.
Is what I am trying to do possible?
Welcome to CircleCI Discuss! You’re experiencing the type error because the cypress/run job expects a boolean parameter. The parameters are evaluated when the configuration is parsed, so unfortunately you would not be able to pass in an environment variable to the record parameter in this case.
However, you may be interested in making this a pipeline parameter instead. https://circleci.com/docs/2.0/pipeline-variables/#pipeline-parameters-in-configuration You won’t be able to update it on the fly within the CircleCI UI, but you would be able to dynamically set it by triggering a pipeline through our v2 API: https://circleci.com/docs/api/v2/#operation/triggerPipeline
I hope that helps!
Interesting, thank you.
Part of the reason I was looking into the UI variables is because I don’t want to have to do code changes to switch recording on and off. We trigger all of our builds through our Bitbucket integration and not through the API, can we set these pipeline parameters on Bitbucket’s side?