我想向其余 API 发送有关部署状态的报告。
它应该独立于部署作业(因为 $IMAGE2 依赖性),因为我想在其他项目中使用报告作业。所以我在 Gitlab CI 中创建了两个作业,如下所示:
deploy:
stage: deploy
image: $IMAGE1
script:
- cd ${CI_PROJECT_DIR} && echo 'Failed' > deployment-status
# some codes to deploy and exit 1 if not successful
- cd ${CI_PROJECT_DIR} && echo 'Passed' > deployment-status #This line run only when deployment is successful
when: manual
artifacts:
when: always
paths:
- deployment-status
report-deployment:
stage: post-deploy
image: $IMAGE2
script:
- cd ${CI_PROJECT_DIR} && cat deployment-status
# some codes to report the status of deployment to …Run Code Online (Sandbox Code Playgroud)