How do we skip ChildPipeline or make it succeeded if there is empty generated-config.yml
, basically no changes to be generated
generate-config:
stage: build
before_script:
- apt-get update -y
- apt-get -y install git zip unzip wget jq apt-transport-https ca-certificates gnupg python3 > /dev/null 2>&1
script:
- python3 python/generate-jobs.py
artifacts:
paths:
- generated-config.yml
tags:
- aws
- prd
validate-generated-config:
stage: validate
script: |
if [ -s generated-config.yml ]; then
echo "Child pipeline configuration found."
else
echo "No child pipeline configuration found, skipping child pipeline trigger."
touch skip-trigger
exit 0
fi
artifacts:
paths:
- generated-config.yml
- skip-trigger
needs:
- generate-config
tags:
- aws
- prd
child-pipeline:
stage: apply-tf
trigger:
include:
- artifact: generated-config.yml
job: generate-config
needs:
- validate-generated-config
rules:
- if: '$CI_COMMIT_REF_NAME == "branch"'
exists:
- generated-config.yml
- when: always