Gitlab CI 循环
Gitlab CI loops
我正在尝试一个需要为同一文件创建 4 个不同版本的用例。我在 gitlab ci 中使用循环来完成这个任务。假设“sample.json”为需要创建四个版本的文件,且该文件可用。
作业中的代码片段 -
script:
- i=1
- no_of_configs=4
- while [ "$i" -le "$no_of_configs" ];
- do
- cp sample.json "sample_$i.json"
- i=$((i + 1))
- done
但是我在执行作业时遇到了无限循环。我也在循环内回显了 i 和 no_of_configs 的值,i 的值正在递增并且 no_of_configs 的值也是常数,即 4。似乎,我在循环条件中遗漏了一些东西.错误是什么?
多行列表已删除换行符,然后传递给 shell。所以写 as-if 它没有换行 - 记得把 ;
放在适当的地方。
script:
- i=1
- no_of_configs=4
- while [ "$i" -le "$no_of_configs" ]; do
cp sample.json "sample_$i.json";
i=$((i + 1));
done
# an alternative:
- seq 4 | xargs -I{} cp sample.json sample_{}.json
我正在尝试一个需要为同一文件创建 4 个不同版本的用例。我在 gitlab ci 中使用循环来完成这个任务。假设“sample.json”为需要创建四个版本的文件,且该文件可用。
作业中的代码片段 -
script:
- i=1
- no_of_configs=4
- while [ "$i" -le "$no_of_configs" ];
- do
- cp sample.json "sample_$i.json"
- i=$((i + 1))
- done
但是我在执行作业时遇到了无限循环。我也在循环内回显了 i 和 no_of_configs 的值,i 的值正在递增并且 no_of_configs 的值也是常数,即 4。似乎,我在循环条件中遗漏了一些东西.错误是什么?
多行列表已删除换行符,然后传递给 shell。所以写 as-if 它没有换行 - 记得把 ;
放在适当的地方。
script:
- i=1
- no_of_configs=4
- while [ "$i" -le "$no_of_configs" ]; do
cp sample.json "sample_$i.json";
i=$((i + 1));
done
# an alternative:
- seq 4 | xargs -I{} cp sample.json sample_{}.json