A drone CI/CD plugin to send email notifications
Go to file
CSRBot 50a6364f68
Some checks reported errors
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build was killed
chore(deps): update quay.io/skopeo/stable docker tag to v1.15.1
2024-06-01 16:04:35 +00:00
cmd Initial Commit 2022-07-24 20:33:39 +02:00
pkg fix: close smtp client connection 2022-07-26 13:29:21 +02:00
.dockerignore Initial Commit 2022-07-24 20:33:39 +02:00
.drone.yml chore(deps): update quay.io/skopeo/stable docker tag to v1.15.1 2024-06-01 16:04:35 +00:00
.gitignore Initial Commit 2022-07-24 20:33:39 +02:00
.golangci.yml Initial Commit 2022-07-24 20:33:39 +02:00
.markdownlint.yaml Initial Commit 2022-07-24 20:33:39 +02:00
Dockerfile chore(deps): update docker.io/library/alpine docker tag to v3.20 2024-05-22 19:06:47 +00:00
go.mod chore(deps): update module github.com/spf13/viper to v1.18.2 2023-12-18 20:05:59 +00:00
go.sum chore(deps): update module github.com/spf13/viper to v1.18.2 2023-12-18 20:05:59 +00:00
LICENSE Initial Commit 2022-07-24 20:33:39 +02:00
main.go Initial Commit 2022-07-24 20:33:39 +02:00
Makefile fix(makefile): migrate to git.cryptic.systems 2023-06-17 14:46:20 +02:00
manifest.tmpl fix(ci): unsupport armv7 2023-11-07 21:42:39 +01:00
README.md Initial Commit 2022-07-24 20:33:39 +02:00
renovate.json fix(renovate): remove automerge options 2024-01-21 15:03:01 +01:00

drone-email

Build Status

A Drone CI/CD plugin to send build status notifications via email. The plugin is currently available for the following architectures:

  • x86_64 / amd64
  • aarch64 / arm64
  • armv7 / arm

Compile or install the binary locally

Checkout the source code of the project and use make to compile or install the binary locally.

make all          # compile all targets, including shell completions
make drone-email  # compile only the binary
make install      # install the binary with completions locally

Usage

All params can be defined via cli flags. A list of all provided cli-flags will be written to stdout via drone-email --help.

Alternatively can be the flags defined via environment variables or a config file.

Environment variables

name description
DRONE_BUILD_CREATED Unix timestamp when the build has been created
DRONE_BUILD_EVENT Drone event which triggered the build
DRONE_BUILD_FINISHED Unix timestamp when the build has been finished
DRONE_BUILD_LINK URL to the build pipeline
DRONE_BUILD_NUMBER Build number
DRONE_BUILD_STARTED Unix timestamp when the build has been started
DRONE_BUILD_STATUS Build status
DRONE_COMMIT_AUTHOR_NAME Name of the commit author
DRONE_COMMIT_AUTHOR_AVATAR Avatar of the commit author
DRONE_COMMIT_AUTHOR_EMAIL EMail of the commit author
DRONE_COMMIT_BRANCH Commit branch
DRONE_COMMIT_LINK Link to the commit
DRONE_COMMIT_MESSAGE Commit message
DRONE_COMMIT_REF Commit reference
DRONE_COMMIT_SHA Commit sha sum
DRONE_DEPLOY_TO Deploy target
DRONE_JOB_EXIT_CODE Job exit code
DRONE_JOB_FINISHED Unix timestamp when the job has been created
DRONE_JOB_NUMBER Job number
DRONE_JOB_STARTED Unix timestamp when the job has been started
DRONE_JOB_STATUS Job status
DRONE_PREV_BUILD_NUMBER Previous build number
DRONE_PREV_BUILD_STATUS Previous build status
DRONE_PREV_COMMIT_SHA Previous commit sha sum
DRONE_PULL_REQUEST Number of pull-requests
DRONE_REMOTE_URL Clone URL of the repository
DRONE_REPO Name of the repository, including org/owner
DRONE_REPO_AVATAR Avatar of the repository
DRONE_REPO_BRANCH Branch of the repository
DRONE_REPO_LINK URL of the repository
DRONE_REPO_NAME Name of the repository, without org/owner
DRONE_REPO_OWNER Org/Owner of the repository
DRONE_REPO_PRIVATE Private repository
DRONE_REPO_SCM SCM of the repository
DRONE_REPO_TRUSTED Trusted repository
DRONE_TAG Tag
DRONE_YAML_SIGNED Yaml is singed
DRONE_YAML_VERIFIED Yaml is trusted
SMTP_FROM_ADDRESS SMTP-From Address
SMTP_FROM_NAME SMTP-From Name
SMTP_HELO SMTP-HELO\EHLO
SMTP_HOST SMTP-Host
SMTP_MAIL_SUBJECT Overwrite default mail subject template
SMTP_PASSWORD SMTP-Password
SMTP_PORT SMTP-Port
SMTP_START_TLS SMTP-Start-TLS
SMTP_TLS_INSECURE_SKIP_VERIFY Trust insecure TLS certificate
SMTP_TO_ADDRESSES SMTP-To Addresses
SMTP_USERNAME SMTP-Username

Config file

Instead of environment variables, a config.yaml can be places in /etc/drone-email or next to the binary.

The yaml should contain the same parameters as the cli flags. For example:

drone-build-link: https://drone.example.local/max.mustermann/drone-email/1
drone-build-number: 1
drone-build-status: success
drone-build-started: 1656354006
drone-commit-author-email: max@example.local
drone-commit-author-name: Max Mustermann
drone-commit-branch: master
drone-commit-sha: 06b44cbfa054f146881e7234f1773008f006a756
drone-repo: max.mustermann/drone-email
drone-repo-link: https://git.example.local/max.mustermann/drone-email
smtp-from-address: noreply@example.local
smtp-from-name: noreply
smtp-helo: hostname.example.local
smtp-host: smtp1.example.local
smtp-password: my-password
smtp-username: noreply@example.local

Known issues

Multiple success emails despite failed ci step

The drone-runner-kube does not define the environment variable DRONE_PREV_BUILD_STATUS like the drone-runner-docker. This make it impossible to use the correct email template based on the build state of the previous step.

Furthermore, the environment variable DRONE_BUILD_STATUS is always defined as success, even if the build has failed.

Related issues: