For loops in CodeBuild with a static array

Viewed 382

Similar to this answer to a related question: https://stackoverflow.com/a/59968374/2092250

My question is, is it possible to specify to the array to loop over as a vanilla list?

So instead of:

- folders=`ls`
- for value in $folders;
   do
      echo $value;
   done
- echo "run the next command"

I'd like to do:

- folders=[a,b,c]
- for value in $folders;
   do
      echo $value;
   done
- echo "run the next command"

I'm new to YAML/CodeBuild, so I assume this is possible and I just have the syntax wrong somehow.

1 Answers

You can do one thing. Create script file called build.sh copy your shell commands to this file. Store this file in your source repo. Now in build spec simply execute this shell script using

  • bash build.sh or
  • ./build.sh
Related