Search code examples
javaregexjenkinsjenkins-pluginsjenkins-email-ext

BUILD_LOG_EXCERPT in Jenkins


I am trying to fetch an excerpt from the Jenkins Console using the Email-ext plugin. Although I tried using the ${BUILD_LOG_EXCERPT, start="...", end="..."} but all I got was a blank email. Below is the log from the Jenkins Console:

Notify: Transaction "Transaction 2" started.    [MsgId: MMSG-16999]
t=00027899ms: Step Coded line #17: Click on About Us link started    [MsgId: MMSG-205180]   [MsgId: MMSG-205180]
t=00054300ms: Error -205177: Step Coded line #17: Click on About Us link failed - Target object was not found. Identification Method: Descriptors       Snapshot Info [MSH 1 0]    [MsgId: MERR-205177] [MsgId: MERR-205177]

I tried the below line in the Default Content Section of the "Editable Email Notification"

${BUILD_LOG_EXCERPT, start="^Error", end="found$"}

PS: Kindly guide me on how to write a proper RegEx to achieve the result.


Solution

  • You may try using BUILD_LOG_REGEX in order to get your desired solution.

    ${BUILD_LOG_REGEX, regex="Error.*found"}    
    

    Regex Demo