Drone CI does not see secret variables when using

2019-07-27 11:47发布

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: test@test.com
  recipients: [ user@test.com ]

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?

1条回答
狗以群分
2楼-- · 2019-07-27 12:19

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: test@test.com
    recipients: [ user@test.com ]
    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

查看更多
登录 后发表回答