I was wondering if this is possible to pass the error message to the one who run the pipeline.
You could absolutely do that! The way it would work is to create a dynamic pipeline that generates a notify
step and passes the error message inside the script generating the dynamic pipeline.
Here is an example script that would create a notification and passes the user that unblocked a deploy step:
set -eu
echo 'steps:' >> notification.yml
echo ' - label: "🚀 Deploy time"' >> notification.yml
echo ' command: "echo deploy_time"' >> notification.yml
echo ' notify:' >> notification.yml
echo ' - slack:' >> notification.yml
echo ' channels:' >> notification.yml
echo ' - "#test-notifications"' >> notification.yml
echo " message: |
Deployed by $BUILDKITE_UNBLOCKER <$BUILDKITE_UNBLOCKER_EMAIL>" >> notification.yml
buildkite-agent pipeline upload notification.yml
There are other ways to do it, but the idea would be to generate that step as a dynamic pipeline with the info you need in it.
Hope that helps!