Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run for loop in buildspec file of AWS CodeBuild?

I am trying to run a for loop to traverse multiple folders in the cloned code using the following method

commands:
- folders=`ls`
- for value in ${folders}
- do
- some_code_here
- done

Also, I've tried different ways like

- for value in ${folders}; do
- some_code_here
- done

But none of them works.

like image 580
the.vaibhav.rajput Avatar asked Dec 19 '25 21:12

the.vaibhav.rajput


1 Answers

You should write for-loops as one-liner. As CodeBuild merges all lines in one command together, you can write for-loops in a readable format as follows:

- folders=`ls`
- for value in $folders;
   do
      echo $value;
   done
- echo "run the next command"
like image 80
Vikyol Avatar answered Dec 21 '25 22:12

Vikyol



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!