[ 
https://issues.apache.org/jira/browse/LUCENE-9598?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17225554#comment-17225554
 ] 

Uwe Schindler commented on LUCENE-9598:
---------------------------------------

Hi, the current config of the email-ext plugin is the following:

eMail-Contents:
{noformat}
Build: ${BUILD_URL}
Java: ${ENV,var="JAVA_DESC"}

${FAILED_TESTS}

Build Log:
${BUILD_LOG_MULTILINE_REGEX,regex="(?x:                                         
                                             \
                                                                                
                                                                                
    \
(?:.*\\[javac\\]\\s++(?![1-9]\\d*\\s+error).*\\r?\\n)*+.*\\[javac\\]\\s+[1-9]\\d*\\s+error.*\\r?\\n
                           \
                                                                                
                                                                                
    \
|.*\\[junit4\\]\\s+Suite:.*+\\s++                                               
                                                                       \
 (?:.*\\[junit4\\]\\s++(?!Suite:)(?!Completed).*\\r?\\n)*+                      
                                                          \
 .*\\[junit4\\]\\s++Completed\\s+.*<<<\\s*FAILURES!\\r?\\n                      
                                                   \
                                                                                
                                                                                
    \
|.*\\[junit4\\]\\s+JVM\\s+J\\d+:\\s+std(?:out|err)\\s+was\\s+not\\s+empty.*+\\s++
                                         \
 
(?:.*\\[junit4\\]\\s++(?!JVM\\s+\\d+:\\s+std)(?!\\<<<\\s+JVM\\s+J\\d+:\\s+EOF).*\\r?\\n)*+
                           \
 .*\\[junit4\\]\\s++<<<\\s+JVM\\s+J\\d+:\\s+EOF.*\\r?\\n                        
                                                        \
                                                                                
                                                                                
     \
|.*rat-sources:.*\\r?\\n                                                        
                                                                           \
 
(?:\\s*+\\[echo\\]\\s*\\r?\\n|\\s*+\\[echo\\]\\s++(?![1-9]\\d*\\s+Unknown\\s+License)\\S.*\\r?\\n)*+
                 \
 \\s*+\\[echo\\]\\s+[1-9]\\d*\\s+Unknown\\s+License.*\\r?\\n                    
                                                      \
 (?:\\s*+\\[echo\\].*\\r?\\n)*+                                                 
                                                                          \
                                                                                
                                                                                
      \
|(?:.*\\r?\\n){2}.*\\[licenses\\]\\s+MISSING\\s+sha1(?:.*\\r?\\n){2}            
                                                      \
                                                                                
                                                                                
      \
|.*check-licenses:.*\\r?\\n\\s*\\[echo\\].*\\r?\\n                              
                                                                  \
 \\s*\\[licenses\\]\\s+(?:MISSING\\s+LICENSE|CHECKSUM\\s+FAILED).*\\r?\\n       
                                   \
 (?:\\s*+\\[licenses\\].*\\r?\\n)++                                             
                                                                         \
                                                                                
                                                                                
       \
|(?:.*\\[javadoc\\]\\s++(?![1-9]\\d*\\s+(?:error|warning)).+\\r?\\n)*+          
                                                        \
 .*\\[javadoc\\]\\s+[1-9]\\d*\\s+(?:error|warning).*\\r?\\n                     
                                                              \
                                                                                
                                                                                
        \
|.*javadocs-lint:.*\\r?\\n(?:.*\\[exec\\].*\\r?\\n)*+                           
                                                                     \
                                                                                
                                                                                
         \
|.*check.*:.*\\r?\\n                                                            
                                                                                
 \
 (?:\\s*+\\[forbidden-apis\\]\\s*\\r?\\n                                        
                                                                         \
  |\\s*+\\[forbidden-apis\\]\\s++                                               
                                                                           \
    
(?!Scanned\\s+\\d+\\s+(?:\\(and\\s+\\d+\\s+related\\)\\s+)?class\\s+file\\(s\\))\\S.*\\r?\n)*+
                           \
 \\s*+\\[forbidden-apis\\]\\s++                                                 
                                                                            \
   
Scanned\\s+\\d+\\s+(?:\\(and\\s+\\d+\\s+related\\)\\s+)?class\\s+file\\(s\\).*[1-9]\\d*\\s+error\\(s\\)\\.\\r?\\n
    \
                                                                                
                                                                                
          \
|\\S+:\\s*\\r?\\n                                                               
                                                                                
    \
 (?:(?!\\S+:\\s*\\r?\\n)(?!.*:\\s+exec\\s+returned:\\s+[^0]).*\\r?\\n)*+        
                                                           \
 .*:\\s+exec\\s+returned:\\s+[^0](?s:.*+)                                       
                                                                      \
                                                                                
                                                                                
           \
|.*\\[echo\\]\\s+Building\\s+.*\\r?\\n                                          
                                                                           \
 \\s*ivy-fail:\\s*(?:\\r?\\n)+                                                  
                                                                                
 \
 \\s*ivy-configure:\\s*(?:\\r?\\n)+                                             
                                                                            \
 \\s*\\[ivy:configure\\].*(?:\\r?\\n)+                                          
                                                                             \
 .*resolve:.*(?:\\r?\\n)+                                                       
                                                                                
 \
 (?:\\s*\\[ivy:retrieve\\].*\\r?\\n)*                                           
                                                                                
\
 \\s*\\[ivy:retrieve\\]\\s+:::*\\s+(?:ERRORS|FAILED\\s+DOWNLOADS).*\\r?\\n      
                                            \
 (?:\\s*\\[ivy:retrieve\\].*\\r?\\n)*                                           
                                                                                
\
                                                                                
                                                                                
           \
|.*-ecj-javadoc-lint-(?:src|tests):.*\\r?\\n                                    
                                                                          \
 (?:\\s*\\[mkdir].*\\r?\\n)?                                                    
                                                                                
  \
 (?:\\s*\\[ecj-lint\\].*\\r?\\n)*                                               
                                                                                
    \
 \\s*\\[ecj-lint\\].*\\([1-9]\\d*\\s+error.*\\r?\\n                             
                                                                             \
                                                                                
                                                                                
            \
|.*check-lib-versions:.*\\r?\\n                                                 
                                                                              \
 (?:\\s*\\[echo\\].*\\r?\\n)?                                                   
                                                                                
  \
 (?:\\s*\\[libversions\\].*\\r?\\n)*                                            
                                                                                
 \
 \\s*\\[libversions\\].*[1-9]\\d*\\s+error.*\\r?\\n                             
                                                                          \
                                                                                
                                                                                
            \
|.*-validate-source-patterns:.*\\r?\\n                                          
                                                                          \
 (?:\\s*\\[source-patterns\\].*\\r?\\n)+                                        
                                                                            \
                                                                                
                                                                                
            \
|.*\\r?\\n.*Full\\s+thread\\s+dump(?s:.*+)                                      
                                                                       \
                                                                                
                                                                                
            \
|.*(?:FATAL|ERROR):(?s:.*+)                                                     
                                                                         \
                                                                                
                                                                                
            \
|.*\\#\\s+A\\s+fatal\\s+error\\s+has\\s+been\\s+detected\\s+by\\s+the\\s+Java\\s+Runtime\\s+Environment:(?s:.*+)
          \
                                                                                
                                                                                
            \
|.*\\#\\s+There\\s+is\\s+insufficient\\s+memory\\s+for\\s+the\\s+Java\\s+Runtime\\s+Environment\\s+to\\s+continue\\.(?s:.*+)
 \
                                                                                
                                                                                
            \
|.*BUILD\\s+FAILED(?s:.*+)                                                      
                                                                          \
                                                                                
                                                                                
            \
|(?:.*\\[repro\\].*\\r?\\n)+                                                    
                                                                                
   \
)"}
{noformat}

The pre-send Groovy-Script is:

{noformat}
def subject = msg.getSubject();
def env = build.getEnvironment(listener);
if (env['JAVA_DESC']?.contains('UnlockExperimentalVMOptions')) {
  subject = subject.replace('[JENKINS]','[JENKINS-Experimental-GC]');
  msg.setSubject(subject, 'UTF-8');
  msg.setHeader('X-Priority', '5 (Low)');
} else if (subject?.contains('-ea-b') || subject?.contains('-ea+')) {
  subject = subject.replace('[JENKINS]','[JENKINS-EA]');
  msg.setSubject(subject, 'UTF-8');
  msg.setHeader('X-Priority', '5 (Low)');
}

maxLength = 100000;
trailingLength = 10000;
bodyPart = msg.getContent().getBodyPart(0);
body = bodyPart.getContent();
bodyLength = body.length();
logger.println("[Email-ext] Notification email body length: " + bodyLength);
if (bodyLength > maxLength) {
  text = new StringBuilder();
  text.append(body.substring(0, maxLength - trailingLength));
  text.append("\n\n[...truncated too long message...]\n\n");
  text.append(body.substring(bodyLength - trailingLength));
  bodyPart.setText(text.toString(), "UTF-8");
  logger.println("[Email-ext] Reduced notification email body length to: " + 
text.length());
}
{noformat}

This was copied from policeman Jenkins. There's its part of global config, so 
it's easy to change centrally.

On ASF Jenkins its copypasted into every job, so a curl-based script aka "HTTP 
GET config.xml | patch config.xml | HTTP PUT config.xml" seems the best option. 
You have to create an API token first.

> Improve the summary of Jenkins emails on failure
> ------------------------------------------------
>
>                 Key: LUCENE-9598
>                 URL: https://issues.apache.org/jira/browse/LUCENE-9598
>             Project: Lucene - Core
>          Issue Type: Improvement
>            Reporter: Dawid Weiss
>            Priority: Minor
>
> Where are the patterns that drive what's extracted from the console logs sent 
> to builds mailing list? I think these could be improved to include more 
> context starting after "FAILURE" - then you know which task failed exactly, 
> not just that the build failed. 
> {code}
> FAILURE: Build failed with an exception.
> * What went wrong:
> Execution failed for task ':solr:solr-ref-guide:checkLocalJavadocLinksSite'.
> > Process 'command '/usr/local/asfpackages/java/jdk-11.0.6/bin/java'' 
> > finished with non-zero exit value 255
> * Try:
> Run with --stacktrace option to get the stack trace. Run with --info or 
> --debug option to get more log output. Run with --scan to get full insights.
> * Get more help at https://help.gradle.org
> Deprecated Gradle features were used in this build, making it incompatible 
> with Gradle 7.0.
> Use '--warning-mode all' to show the individual deprecation warnings.
> See 
> https://docs.gradle.org/6.6.1/userguide/command_line_interface.html#sec:command_line_warnings
> BUILD FAILED in 1h 6m 1s
> 852 actionable tasks: 852 executed
> Build step 'Invoke Gradle script' changed build result to FAILURE
> Build step 'Invoke Gradle script' marked build as failure
> Archiving artifacts
> Recording test results
> Email was triggered for: Failure - Any
> Sending email for trigger: Failure - Any
> [Email-ext] Notification email body length: 446
> Sending email to: bui...@lucene.apache.org
> Finished: FAILURE
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org
For additional commands, e-mail: issues-h...@lucene.apache.org

Reply via email to