-
-
Save Firemoon777/3e7aa20d2326f6a5fe4e0959edf47e1a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Воркфлоу описывает базовые условия, когда пайплайн должен создаваться | |
workflow: | |
rules: | |
# Пайплайн в контексте MR | |
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"' | |
# Если контекст коммита, но есть открытый MR, то НЕ запускаемся | |
- if: '$CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS' | |
when: never | |
# Одинокий коммит ИЛИ тэг | |
- if: '$CI_COMMIT_BRANCH || $CI_COMMIT_TAG' | |
generate-pipeline: | |
image: python:3.9 | |
script: | |
- pip install pyyaml | |
- python3 pipeline.py > output.yml | |
artifacts: | |
paths: | |
- output.yml | |
child-pipeline: | |
stage: test | |
needs: | |
- generate-pipeline | |
trigger: | |
include: | |
- artifact: output.yml | |
job: generate-pipeline |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import yaml | |
pipeline = dict( | |
workflow=dict( | |
rules=[ | |
{"if": '$CI_PIPELINE_SOURCE == "parent_pipeline"'} | |
] | |
), | |
job1=dict( | |
image="python:3.9", | |
script=[ | |
"echo success" | |
] | |
) | |
) | |
print(yaml.safe_dump(pipeline)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment