appleboy / drone-discord

Drone plugin for sending message to Discord channel using Webhook
MIT License
35 stars 20 forks source link

Doesn't seem to run, says step successful? #29

Open Shyclyde opened 4 years ago

Shyclyde commented 4 years ago

Hey there, somehow I got this to run the first time, but every time after it looks like it just seems to skip the actual step but comes up as a pass. Here's my step:

- name: discord start notification
  image: appleboy/drone-discord
  settings:
    webhook_id:
      from_secret: discord_webhook_id
    webhook_token:
      from_secret: discord_webhook_id
    message: "Rebuilding..."

Something I'm doing wrong maybe? Triple checked the secrets are correct. I can run it in a docker container just fine with something like below with test env variables:

docker run -e WEBHOOK_ID=$HOOK_ID -e WEBHOOK_TOKEN=$HOOK_TOKEN -e MESSAGE=test appleboy/drone-discord

Not sure if this is an issue or if I'm missing something?

Thanks!

Shyclyde commented 4 years ago

Additionally, as a test I had added this to the step:

  commands:
  - echo "test"

Just to see if it was skipping the step entirely, but that seems to run fine. Also tried putting the secrets inline instead of through from_secret:, same result of the step passing with no actions.

more-pepsi commented 2 years ago

Me also. I'm arm64/v8. Did you have any luck?

lukeawyatt commented 2 years ago

Within this YAML above, he's sharing the same value secret value for both the webhook_id and webhook_token. Without seeing the origin of said secret, I suspect this was the issue.

more-pepsi commented 2 years ago
- name: Message build status
  image: appleboy/drone-discord
  settings:
    webhook_id:
      from_secret: discord_id
    webhook_token:
      from_secret: discord_token
    message: >
      {{#success build.status}}
      build {{build.number}} succeeded. Good job.
      {{else}}
      build {{build.number}} failed. Fix me please.
      {{/success}}
    when:
      status: [ success, failure ]

image

See nothing. The webhook is set for the general channel. Removing the mesage field has got it working. The issue may be that the step runs for both general builds and pull requests? But I would have expected at least one notification. It will take me little to read the code, i'm a go newbie

lukeawyatt commented 2 years ago

It has been a bit since I touched this, but my message value looks like this:

message: "{{#success build.status}}✅{{else}}❌{{/success}}  Repository `[{{repo.name}}/{{commit.branch}}]` triggered by event `[{{uppercase build.event}}]` for build.\n    - Commit [[{{commit.sha}}]({{commit.link}})]\n    - Author `[{{commit.author}} / {{commit.email}}]`\n    - Message: {{commit.message}}    - Drone build [[#{{build.number}}]({{build.link}})] reported `[{{uppercase build.status}}]` at `[{{datetime build.finished \"2006.01.02 15:04\" \"\"}}]`\n​"

I have a third value for when as well: changed

It's still in production and seems to be working fine daily for my use cases. Remembering back to the first setup, I think the message field held me up quite a bit. Maybe fill in the pieces above and see if it works as expected, then modify the message value to your need?

more-pepsi commented 2 years ago

It has been a bit since I touched this, but my message value looks like this:

message: "{{#success build.status}}✅{{else}}❌{{/success}}  Repository `[{{repo.name}}/{{commit.branch}}]` triggered by event `[{{uppercase build.event}}]` for build.\n    - Commit [[{{commit.sha}}]({{commit.link}})]\n    - Author `[{{commit.author}} / {{commit.email}}]`\n    - Message: {{commit.message}}    - Drone build [[#{{build.number}}]({{build.link}})] reported `[{{uppercase build.status}}]` at `[{{datetime build.finished \"2006.01.02 15:04\" \"\"}}]`\n​"

I have a third value for when as well: changed

It's still in production and seems to be working fine daily for my use cases. Remembering back to the first setup, I think the message field held me up quite a bit. Maybe fill in the pieces above and see if it works as expected, then modify the message value to your need?

Thanks man. Just got it working. I added a print of just the status and it worked.

:)

That should be in the docs. I'll add it. Feel free to reject it

lukeawyatt commented 2 years ago

Glad I could help!