Continuous integration 要在每次部署后运行的Gitlab CI作业,以报告状态
我想向rest API发送有关部署状态的报告。Continuous integration 要在每次部署后运行的Gitlab CI作业,以报告状态,continuous-integration,gitlab,gitlab-ci,gitlab-ci-runner,Continuous Integration,Gitlab,Gitlab Ci,Gitlab Ci Runner,我想向rest API发送有关部署状态的报告。 它应该独立于部署作业(因为$IMAGE2依赖关系),因为我希望在其他项目中使用报表作业。 因此,我在Gitlab CI中创建了两个职位,如下所示: deploy: stage: deploy image: $IMAGE1 script: - cd ${CI_PROJECT_DIR} && echo 'Failed' > deployment-status # some codes to deploy
它应该独立于部署作业(因为$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 an API
when: always
needs: ["deploy"]
在上面的解决方案中,依赖于部署,我使用Passed/Failed填充deployment status
,并在下一个作业中使用deployment status
工件文件来获取有关部署状态的信息并报告它
上述解决方案存在一些问题:-除非触发手动作业,否则管道状态将为
正在运行
。(由于报告部署
作业需要部署
)-如果我尝试两次触发
deploy
作业,则只会向API发送一个报告。你好。为什么不将API调用放在
deploy
阶段呢?我希望report deployment
作业是一个单独的作业(类似于模板),可以在其他项目中使用。合并$IMAGE1和$IMAGE2依赖项是不干净的。