Search code examples
jenkinsgroovyemail-notificationsconsole-output

Jenkins pipeline email notifications with some part of console output in email


I am running an Automated test suite on jenkins and I am able to get the status of the job using Email ext plugin. I want to include only some part of build log in email is there any way that I can do that using groovy syntax? Any help would be appreciated!


Solution

  • def notifyFailed() {
        emailext (
          subject: "FAILED : Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'",
          body: '''<p><font size="8" color="red">Build Failure!</font></p>
        <p>Check console output at &QUOT;<a href='${BUILD_URL}consoleText'>${JOB_NAME} [${BUILD_NUMBER}]</a>&QUOT;</p>
        ${BUILD_LOG_REGEX, regex="^.*?*****.*?$", linesBefore=0, linesAfter=999, maxMatches=10, showTruncatedLines=false,escapeHtml=false}''',