Hi everyone,
I want to continue the execution of job only if the result of a bash script is true.
I tried the solution here using env variables, however as the caveat there says, it doesn’t work on when
which is exactly what we need as we perform complex conditions inside the bash script.
Is it possible to do that?
This is an example of our configuration file:
check_for_condition: &check_for_condition
name: Check for my special condition
command: |
sudo chmod +x /home/circleci/project/script.sh
bash /home/circleci/project/script.sh
# This step will populate the environemnt variable MY_FLAG, to be used in the next step
build-job:
executor: python
parameters:
my_flag:
type: env_var_name # note the special type
default: MY_FLAG
steps:
- checkout
### Check for my condition
- run: *check_for_condition
- run: echo "Conditions were met? 'my_flag'=$<<parameters.my_flag>>"
- when:
condition:
or:
- equal: [main, <<parameters.branch>>]
- equal: ["true", $<<parameters.my_flag>>]
steps:
### Run if condition above is met
- next_steps_here:
- next_steps_here:
- next_steps_here:
- next_steps_here: