Pipelines GitLab avec tâches parallèles
L'image GitLab Docker prend en charge la création de changements dans les pipelines GitLab contenant des tâches parallèles.
Remarque :
Si votre pipeline GitLab comporte des tâches parallèles, il est préférable d'utiliser l'image GitLab Docker plutôt que when:manual. Pour obtenir des informations détaillées sur l'image GitLab Docker, consultez Implémenter des actions personnalisées pour les pipelines utilisant une image de conteneur Docker générique.
Exemple de pipeline yaml illustrant des tâches parallèles :
image: servicenowdocker/sndevops:3.1.0 # Update docker version per your current version.
stages:
- pre-build
- build
- test
- pre-prod
- prod
Scan PreProd:
stage: pre-build
script:
- echo $CI_JOB_NAME
Check policies in PreProd:
stage: build
needs:
- job: "Scan PreProd"
script:
- exit 1 # Simulating a failed test job
allow_failure: true # Allow this job to fail without stopping the pipeline
Check policies in Prod:
stage: build
needs:
- job: "Scan PreProd"
script:
- echo $CI_JOB_NAME
Deploy App in Test:
stage: test
needs:
- job: "Scan PreProd"
script:
- echo $CI_JOB_NAME
Deploy App in PreProd:
stage: pre-prod
needs:
- job: "Deploy App in Test"
- job: "Check policies in PreProd"
allow_failure: false
script:
- echo $CI_JOB_NAME
- sndevopscli create change -p "{\"changeStepDetails\":{\"timeout\":3600,\"interval\":100},\"autoCloseChange\":true}"
Deploy App in Prod:
stage: prod
needs:
- job: "Deploy App in PreProd"
- job: "Check policies in Prod"
allow_failure: false
script:
- echo $CI_JOB_NAME
- sndevopscli create change -p "{\"changeStepDetails\":{\"timeout\":3600,\"interval\":100},\"autoCloseChange\":true}"