how to get a job's result of gitlab ci stage

Viewed 197

I have a gitlab ci pipeline like below, and there is a bash script notify.sh which will send different notification depends on stage build result(success or failed), currently I use a arg --result to control the logic, and I write two jobs for stage notify(success-notify and failed-notify) and assign the value of --result manually. Is there a way to get the stage build result directly(like STAGE_BUILD_STATE) instead of use statement when?

---
stages:
- build
- notify

build:
  stage: build
  script:
  - build something

success-notify:
  stage: notify
  script:
  - bash notify.sh --result success

failed-notify:
  stage: notify
  script:
  - bash notify.sh --result failed
  when: on_failure

0 Answers
Related