本文介绍了使用无人机电子邮件插件时,无人机CI不会看到秘密变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 drone-ci (0.8.0-rc.5)作为CI工具和 drone-email 插件来发送电子邮件.如果构建成功或失败,我想发送通知.我使用Gmail SMTP服务器发送电子邮件.

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.

我的.drone.yml文件:

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: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

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

当我对yml文件中的值进行硬编码时,通知起作用.所以我想知道我在做些什么秘密或如何解决这种情况?

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?

推荐答案

您正在使用的语法${secret}在无人机0.6中已弃用,并替换为以下语法:

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.

进一步阅读

  • http://docs.drone.io/manage-secrets/
  • http://docs.drone.io/secrets-not-working/#variable-expansion
  • http://docs.drone.io/release-0.6.0 (see breaking changes section)

这篇关于使用无人机电子邮件插件时,无人机CI不会看到秘密变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 11:00