Aliaksei Maniuk
Aliaksei Maniuk

Reputation: 1664

Drone CI does not see secret variables when using drone-email plugin

I'm using drone-ci (0.8.0-rc.5) as CI tool and drone-email plugin for sending emails. I would like to send notifications if a build succeeded or failed. I use the Gmail SMTP server for sending emails.

My .drone.yml file:

notify:
  image: drillster/drone-email
  host: ${EMAIL_HOST}
  port: ${EMAIL_PORT}
  username: ${EMAIL_USERNAME}
  password: ${EMAIL_PASSWORD}
  from: [email protected]
  recipients: [ [email protected] ]

Secrets are configured like on the picture below: enter image description here When the build finishes, I receive following exception:

time="2017-09-20T02:14:10Z" level=error msg="Error while dialing SMTP server: dial tcp :587: getsockopt: connection refused" dial tcp :587: getsockopt: connection refused

When I hardcode values in yml file, notifications work. So I'm wondering what I'm doing wrong with secrets or how to fix this situation?

Upvotes: 2

Views: 2966

Answers (1)

Brad Rydzewski
Brad Rydzewski

Reputation: 2563

The syntax you are using, ${secret}, was deprecated in drone 0.6 and replaced with the following syntax:

pipeline:
  notify:
    image: drillster/drone-email
    from: [email protected]
    recipients: [ [email protected] ]
    secrets: [EMAIL_HOST, EMAIL_PORT, EMAIL_USERNAME, EMAIL_PASSWORD]

The above syntax instructs drone to provide the requested secrets to the plugin. The secrets are exposed into the container as environment variables and consumed by the plugin.

Further reading

Upvotes: 3

Related Questions