Hi,
I need to use a for loop in run command that goes through the fields of an array that is given as parameters and run the command. I’m wondering how that can be done in circleci orb?
I couldn’t find this in documentations. Here is what I need:
At the moment we don’t have a list type parameter, just string, enum, boolean, and integer. We have a bit more information in our “Reusable Config Reference Guide”.
With that said, I think you can still accomplish what you are looking for by using a string parameter. I setup a quick config to demonstrate this:
version: 2.1
jobs:
build:
parameters:
envs:
description: project environments
default: "dev test stage prod"
type: string
docker:
- image: circleci/node
steps:
- checkout
- run:
name: Validate terraform code
command: |
printf "Validating terraform code\n"
for i in <<parameters.envs>>; do
echo "test: $i"
done
workflows:
build-deploy:
jobs:
- build
Which results in:
Hope the above helps clarify and if you need anything else please let me know!