T
Task3mo ago
mnapoleon

Is it possible to set an env value in a task from a variable passed in when call the task?

I would like to call a task like
task start-service use_mocks=true
task start-service use_mocks=true
And have that set a env value in my start-service task like
start-service:
vars:
use_mocks: false
env:
user_mocks: {{.use_mocks}}
start-service:
vars:
use_mocks: false
env:
user_mocks: {{.use_mocks}}
That exact setup doesn't but I'm wondering if there is another way to do it? I want a default value of false and if passed it uses the passed in var
1 Reply
andreynering
andreynering3mo ago
@mnapoleon Try something like this:
start-service:
env:
USER_MOCKS: '{{.USER_MOCKS | default "my-default-value"}}'
start-service:
env:
USER_MOCKS: '{{.USER_MOCKS | default "my-default-value"}}'

Did you find this page helpful?