需要在Gitlab CI job的关键字script中执行一个if判断或者for循环等
初始配置是这样的
build-job:
stage: deploy
only:
- develop
script:
- set +e
- 一行一行的命令...
- set -e
if多行执行没报错,但每次啥都执行了
build-job:
stage: deploy
only:
- develop
script:
- set +e
- 一行一行的命令...
- if [ "$latest_update_time" != "$formart_date" ]
- then
- echo “开始干活...”
- fi
- set -e
1、在shell脚本内执行
build-job:
stage: deploy
only:
- develop
script:
- /bin/bash ./build.sh
build.sh内容
#!/bin/bash
if [ "$latest_update_time" != "$formart_date" ]
then
echo “开始干活...”
fi
2、写成一行
build-job:
stage: deploy
only:
- develop
script:
- set +e
- 一行一行的执行命令...
- if [ "$latest_update_time" != "$formart_date" ]; then echo “开始干活...”; fi
- set -e