Search code examples
jenkinsjenkins-pipelinejenkins-pluginsjenkins-cli

How to add Bit Bucket commit details in email after build complete in Jenkins


Currently i am using Jenkins for CI/CD purpose and Email Extension Plugin for sending mail. I need to include commit details and changes in email and send it to default recipient after build completed successfully.


Solution

  • Simply specify '${SCRIPT,template="groovy-html.template"}' as the body of the email.

    emailext (
        mimeType: 'text/html',
        subject: '$BUILD_STATUS: $PROJECT_NAME - Build # $BUILD_NUMBER',
        to: '$DEFAULT_RECIPIENTS',
        body: '${SCRIPT,template="groovy-html.template"}'
    )
    

    This is one of the default email templates that also displays the changelog with color coded build status.

    enter image description here

    [1]: https://i.sstatic.net/TGxxL.png