Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The plugin sends notifications as successful. #162

Open
sviatoslav6 opened this issue Jun 28, 2023 · 3 comments
Open

The plugin sends notifications as successful. #162

sviatoslav6 opened this issue Jun 28, 2023 · 3 comments

Comments

@sviatoslav6
Copy link

The plugin sends notifications as successful, even when some steps in the pipeline have failed and resulted in an error.

My pipeline

kind: pipeline
type: kubernetes
name: test

trigger:
  branch:
    - master

clone:
  disable: true

steps:
  - name: test
    image: bitnami/git
    environment:
      SLACK_WEBHOOK:
        from_secret: SLACK_WEBHOOK
    commands:
      - kubectl get pod
    when:
      event: [push]

  - name: slack-notify
    image: plugins/slack
    environment:
      SLACK_WEBHOOK:
        from_secret: SLACK_WEBHOOK
    settings:
      webhook: $${SLACK_WEBHOOK}
      channel: my-channel
      template: >

        {{#success build.status}} ✔ {{ else }} :x: {{/success}} {{ uppercasefirst build.status }}: Build #{{ build.number }} * (type: `{{ build.event }}`)

        Repository:  <https://github.com/{{ repo.name }}>

        Commit: <https://github.com/{{ repo.owner }}/{{ repo.name }}/commit/{{ build.commit }}|{{ truncate build.commit 8 }}>

        Branch: <https://github.com/{{ repo.owner }}/{{ repo.name }}/commits/{{ build.branch }}|{{ build.branch }}>

        Author: {{ build.author }}

        Build: <{{ build.link }}| Drone Build {{ build.number }} ↗>
    when:
      event: [push]
      status: [success, failure]
      branch: [master]
    depends_on:
      - test

step test ends with an error, because no such command

image

in the slack message that the build was successful

image

@sviatoslav6
Copy link
Author

When I use tag 1.4.1, everything works as before

image

@thelazyoxymoron
Copy link

Facing the same issue

@casdr
Copy link

casdr commented Oct 31, 2023

Something weird I noticed is that when I add a step that runs the export command, it shows the following:

export DRONE_BUILD_STATUS='success'

This explains why the plugin shows the build as being successful, but it doesn't explain why it did detect a failed build in the previous version. I couldn't really find a related change in the diffs between tag 1.4.1 (and earlier) and master.

One workaround for this is moving the plugin to a separate stage, which depends on the 'main' stage and has the following trigger:

---
[build stage]

---
kind: pipeline
type: kubernetes
name: notify slack
depends_on:
  - build stage

triggers:
  status:
    - success
    - failure

steps:
[ slack step ]

When testing with the export command, you'll also see te following in this case:

export DRONE_BUILD_STATUS='failure'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants