Cannot send email with woodpecker-next #1

Closed
opened 2023-02-06 21:49:24 +01:00 by waldner · 3 comments

I'm struggling to get the plugin to work. Here are the main issues. I started with this configuration:

  email:
    when:
      status:
        - failure
    image: deblan/woodpecker-email
    settings:
      host: mail.foo.com
      username:
        from_secret: email_username
      password:
        from_secret: email_password
      from.address: woodpecker@foo.com
      skip_verify: true
      recipients: [ me@foo.com ]
      recipients_only: true

I'm using woodpecker-next, with global secrets enabled (and email credentials stored there). With the above config, the plugin was not working and I saw in the logs:

woodpecker-server   | {"level":"error","error":"no secret found for \"email_username\"","time":"2023-02-06T20:30:22Z","message":"paramsToEnv"}

possibily because the secret is looked up in the repo's secrets and not (also) in the global secrets, which don't exist in woodpecker-stable. So after looking at the source ans seeing that username and password can also be passed via env variable, changing the configuration as follows fixed that:

  email:
    when:
      status:
        - failure
    secrets:
      - source: email_username
        target: plugin_username
      - source: email_password
        target: plugin_password
    image: deblan/woodpecker-email
    settings:
      host: mail.foo.com
      from.address: woodpecker@foo.com
      skip_verify: true
      recipients: [ me@foo.com ]
      recipients_only: true

But now when it has to send email it fails with this message:

time="2023-02-06T20:37:21Z" level=error msg="Could not send email to \"me@foo.com\": gomail: could not send email 1: gomail: invalid address \"\": mail: no address" 
gomail: could not send email 1: gomail: invalid address "": mail: no address

Is this also related to my usage of woodpecker-next? If so, is a fix planned?

Thanks.

I'm struggling to get the plugin to work. Here are the main issues. I started with this configuration: ``` email: when: status: - failure image: deblan/woodpecker-email settings: host: mail.foo.com username: from_secret: email_username password: from_secret: email_password from.address: woodpecker@foo.com skip_verify: true recipients: [ me@foo.com ] recipients_only: true ``` I'm using woodpecker-next, with global secrets enabled (and email credentials stored there). With the above config, the plugin was not working and I saw in the logs: ``` woodpecker-server | {"level":"error","error":"no secret found for \"email_username\"","time":"2023-02-06T20:30:22Z","message":"paramsToEnv"} ``` possibily because the secret is looked up in the repo's secrets and not (also) in the global secrets, which don't exist in woodpecker-stable. So after looking at the source ans seeing that username and password can also be passed via env variable, changing the configuration as follows fixed that: ``` email: when: status: - failure secrets: - source: email_username target: plugin_username - source: email_password target: plugin_password image: deblan/woodpecker-email settings: host: mail.foo.com from.address: woodpecker@foo.com skip_verify: true recipients: [ me@foo.com ] recipients_only: true ``` But now when it has to send email it fails with this message: ``` time="2023-02-06T20:37:21Z" level=error msg="Could not send email to \"me@foo.com\": gomail: could not send email 1: gomail: invalid address \"\": mail: no address" gomail: could not send email 1: gomail: invalid address "": mail: no address ``` Is this also related to my usage of woodpecker-next? If so, is a fix planned? Thanks.
waldner changed title from Cannot send email to Cannot send email with woodpecker-next 2023-02-06 21:52:28 +01:00
Owner

Hi,

Can you replace from.address with from and try again?

The plugin does not retrieve secrets itself so that coult be a bug from woodpecker. I will run tests.

Hi, Can you replace `from.address` with `from` and try again? The plugin does not retrieve secrets itself so that coult be a bug from woodpecker. I will run tests.
Author

So changing from.address to from made it work. This is my currently working config:

  email:
    when:
      status:
        - failure
    secrets:
      - source: email_username
        target: plugin_username
      - source: email_password
        target: plugin_password
    image: deblan/woodpecker-email
    settings:
      host: mail.foo.com
      #username:
      #  from_secret: email_username
      #password:
      #  from_secret: email_password
      from: woodpecker@foo.com
      skip_verify: true
      recipients: [ "me@foo.com" ]
      recipients_only: true
So changing `from.address` to `from` made it work. This is my currently working config: ``` email: when: status: - failure secrets: - source: email_username target: plugin_username - source: email_password target: plugin_password image: deblan/woodpecker-email settings: host: mail.foo.com #username: # from_secret: email_username #password: # from_secret: email_password from: woodpecker@foo.com skip_verify: true recipients: [ "me@foo.com" ] recipients_only: true ```
Owner

Global settings works!

Global settings works!
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: deblan/woodpecker-email#1
No description provided.