Drillster / drone-email

Drone plugin for sending email notifications
Apache License 2.0
43 stars 43 forks source link

receive always success email in k8s environments even ci build has failed #69

Open volker-raschek opened 1 year ago

volker-raschek commented 1 year ago

Hi, I noticed that I receive always success emails even when a build has failed. I checked out the mail plugin in detail and find out that there are two environment variables DRONE_BUILD_STATUS and DRONE_PREV_BUILD_STATUS. DRONE_BUILD_STATUS contains always success and DRONE_PREV_BUILD_STATUS is not defined. This leads to the issue, that I always get success emails. Here a list of all environment variables passed into the container - some values are marked.

DRONE=true
DRONE_BRANCH=master
DRONE_BUILD_ACTION=
DRONE_BUILD_CREATED=1658649177
DRONE_BUILD_DEBUG=false
DRONE_BUILD_EVENT=push
DRONE_BUILD_FINISHED=1658649426
DRONE_BUILD_LINK=<marked>
DRONE_BUILD_NUMBER=41
DRONE_BUILD_PARENT=0
DRONE_BUILD_STARTED=1658649188
DRONE_BUILD_STATUS=success
DRONE_BUILD_TRIGGER=@hook
DRONE_CARD_PATH=/dev/stdout
DRONE_COMMIT=8210bcea0c335221c232a2bdc6c08f4b13e70b1a
DRONE_COMMIT_AFTER=8210bcea0c335221c232a2bdc6c08f4b13e70b1a
DRONE_COMMIT_AUTHOR=<marked>
DRONE_COMMIT_AUTHOR_AVATAR=<marked>
DRONE_COMMIT_AUTHOR_EMAIL<marked>
DRONE_COMMIT_AUTHOR_NAME=<marked>
DRONE_COMMIT_BEFORE=9c8030a7a6354d6d72c23369d4db76d7c03deb50
DRONE_COMMIT_BRANCH=master
DRONE_COMMIT_LINK=<marked>
DRONE_COMMIT_MESSAGE=fix
DRONE_COMMIT_REF=refs/heads/master
DRONE_COMMIT_SHA=8210bcea0c335221c232a2bdc6c08f4b13e70b1a
DRONE_DEPLOY_ID=0
DRONE_DEPLOY_TO=
DRONE_DOCKER_VOLUME_ID=drone-gktxkk4ntym6h8yar977
DRONE_GIT_HTTP_URL=<marked>
DRONE_GIT_SSH_URL=<marked>
DRONE_PORT=tcp://10.101.222.178:80
DRONE_PORT_80_TCP=tcp://10.101.222.178:80
DRONE_PORT_80_TCP_ADDR=10.101.222.178
DRONE_PORT_80_TCP_PORT=80
DRONE_PORT_80_TCP_PROTO=tcp
DRONE_REMOTE_URL=<marked>
DRONE_REPO=<marked>
DRONE_REPO_BRANCH=master
DRONE_REPO_LINK=<marked>
DRONE_REPO_NAME=<marked>
DRONE_REPO_NAMESPACE=<marked>
DRONE_REPO_OWNER=<marked>
DRONE_REPO_PRIVATE=false
DRONE_REPO_SCM=
DRONE_REPO_VISIBILITY=public
DRONE_SERVICE_HOST=10.101.222.178
DRONE_SERVICE_PORT=80
DRONE_SERVICE_PORT_HTTP=80
DRONE_SOURCE_BRANCH=master
DRONE_STAGE_ARCH=amd64
DRONE_STAGE_DEPENDS_ON=latest-manifest
DRONE_STAGE_FINISHED=1658649426
DRONE_STAGE_KIND=pipeline
DRONE_STAGE_MACHINE=drone-runner-77f474d9cb-zrnwp
DRONE_STAGE_NAME=notification-test
DRONE_STAGE_NUMBER=5
DRONE_STAGE_OS=linux
DRONE_STAGE_STARTED=1658649426
DRONE_STAGE_STATUS=success
DRONE_STAGE_TYPE=kubernetes
DRONE_STAGE_VARIANT=
DRONE_STAGE_VERSION=3
DRONE_STEP_NAME=post-env
DRONE_SYSTEM_HOST=<marked>
DRONE_SYSTEM_HOSTNAME=<marked>
DRONE_SYSTEM_PROTO=https
DRONE_SYSTEM_VERSION=2.12.0
DRONE_TARGET_BRANCH=master
DRONE_WORKSPACE=/drone/src

Is there an other way to determine the build status of the previous step?

Volker

tobias-graf-p commented 11 months ago

@volker-raschek I also experience that ${DRONE_BUILD_STATUS} always prints "success" while {{build.status}} prints either "success" or "failure" depending of the actual result of the pipeline. I would like to use ${DRONE_BUILD_STATUS} in my yml file. Is there a solution for this?