For loops in CodeBuild with a static array

0

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.

질문됨 2년 전1565회 조회
1개 답변
0

You can define a bash array like this:

- folders=("/path1/file1" "/path2/file2" "/path3/file3" )
- for value in ${folders[@]};
   do
      echo $value;
   done
- echo "run the next command"
PPPazos
답변함 2년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠