Pipeline failure but build status success

Hi, i am using plugins/webhook for notification in Node-RED. For some reason the build.status is always success and i dont understand why. i read the following

The build status represents the overall status of all pipelines.

Is it a bug or am i doing something wrong?

.drone.yaml:

---
kind: pipeline
name: validate

steps:
  - name: yamllint
    image: sdesbure/yamllint:latest
    commands:
      - yamllint -c ./.yamllint . 

  - name: docker-compose
    image: tmaier/docker-compose:latest
    commands:
      - docker-compose config -q

---
kind: pipeline
type: docker
name: build

depends_on:
  - validate

steps:
  - name: publish
    image: plugins/docker
    settings:
      username:
        from_secret: docker-registry-username
      password:
        from_secret: docker-registry-password
      registry: docker-registry.theautomation.nl
      repo: docker-registry.theautomation.nl/coen/prd-${DRONE_REPO_NAME}-app
      auto_tag: true

---
kind: pipeline
type: docker
name: upgrade

depends_on:
  - build

steps:
  - name: git pull
    image: appleboy/drone-ssh
    settings:
      host:
        from_secret: ssh_host
      username:
        from_secret: ssh_user
      password:
        from_secret: ssh_password
      script:
        - cd /home/coen/docker-home-services/${DRONE_REPO_NAME}/
        - git pull

  - name: docker compose up
    image: appleboy/drone-ssh
    settings:
      host:
        from_secret: ssh_host
      username:
        from_secret: ssh_user
      password:
        from_secret: ssh_password
      script:
        - cd /home/coen/docker-home-services/${DRONE_REPO_NAME}/
        - docker-compose up -d

  - name: cleanup
    image: appleboy/drone-ssh
    settings:
      host:
        from_secret: ssh_host
      username:
        from_secret: ssh_user
      password:
        from_secret: ssh_password
      script:
        - cd /home/coen/docker-home-services/${DRONE_REPO_NAME}/
        - docker image prune -f

---
kind: pipeline
name: notify webhook

steps:
  - name: send
    image: plugins/webhook
    settings:
      username:
        from_secret: nodered_endpoint_username
      password:
        from_secret: nodered_endpoint_password
      urls: http://***drone/notify
      skip_verify: true
      content_type: application/json
      template: |
        {
          "owner": "{{ repo.owner }}",
          "repo": "{{ repo.name }}",
          "status": "{{ build.status }}",
          "build number": "{{ build.number }}",
          "build link": "{{ build.link }}"
        }
    when:
      status:
      - success
      - failure

Screenshot from 2021-07-26 20-24-35

Webhook result:

payload: object
owner: "theautomation"
repo: "makemkv"
status: "success"
build number: "21"
build link: "https:/****"

the webhook plugin uses the stage status, not the overall pipeline status. Since the stage is passing the webhook emits success in the body. I believe you can modify the template to use the build status, but you would probably need to look at the code to figure it out GitHub - drone-plugins/drone-webhook: Drone plugin for triggering webhook notifications

Thanks thats explains the status :slight_smile:

Is this documented somewhere? how do i know if the {{ build.status }} (for any plugin) is only for the current step or for the overall pipeline?

I’ve never used the template before, should it be something like this?

    template: >
      {{#success build.status}}
        build {{build.number}} succeeded. Good job.
      {{else}}
        build {{build.number}} failed. Fix me please.
      {{/success}}

@bradrydzewski I’ve been looking for a solution for days but without success. I’ve searched the code but don’t know where to look. Can you tell me a littlebit more how to get and send the overall build status?

after a second look at your yaml, I can see that your notify webhook stage is missing depends_on which means it is immediately executed (at the same time as your validate stage). The webhook plugin is therefore being invoked before any failure happens, hence the reason you are seeing a success status in the payload.

kind: pipeline
name: notify webhook

steps:
  - name: send
    image: plugins/webhook
    settings: ...
-    when:
-      status:
-      - success
-      - failure

+trigger:
+  status:
+    - success
+    - failure

+depends_on:
+  - upgrade
1 Like

thanks so much! it is working now! :slight_smile: