Hello @Pierre KUHN and thank you for reaching out to the Community!
From your description, I assume you are using the atlassian/email-notify pipe.
While there's no default environment variable in the pipeline containing the commit message, you can use the $BITBUCKET_COMMIT env variable to get the commit message using the below git command :
git log --format=%B -n 1 $BITBUCKET_COMMIT
and then export the output of that command (the commit message) to a new custom environment variable.
export COMMIT_MESSAGE=$(git log --format=%B -n 1 $BITBUCKET_COMMIT)
All the default env variables and any custom env variable you create during the step are available inside the pipe and can be referenced as you would normally do in the script.
Using the concept above, following is an example of including the commitID and commit message to both the Subject and Body of the email message :
pipelines:
default:
- step:
script:
- git log --format=%B -n 1 $BITBUCKET_COMMIT
- export COMMIT_MESSAGE=$(git log --format=%B -n 1 $BITBUCKET_COMMIT)
- echo $COMMIT_MESSAGE
- pipe: atlassian/email-notify:0.9.0
variables:
USERNAME: 'myemail@email.com'
PASSWORD: $MAIL_PASS
FROM: 'myemail@email.com
TO: 'myemail@email.com'
HOST: 'smtp.gmail.com'
SUBJECT: 'Email for commit $BITBUCKET_COMMIT - $COMMIT_MESSAGE'
BODY_PLAIN: 'Email send from Bitbucket Pipeline executed on commit $BITBUCKET_COMMIT - $COMMIT_MESSAGE'
Hope that helps! Let me know in case you have any questions.
Thank you, @Pierre KUHN !
Patrik S
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.