No matter what I put in BUILD_LOG_EXCERPT, all I get is an email with an empty body, thus could use some assistance.
I have a java program that writes to console. Snippet of Jenkins console output looks like this:
...
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building project1 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- exec-maven-plugin:1.4.0:java (default-cli) @ project1 ---
Parameters provided: SG, 100, 1000
query: select COUNT(*) from table1 where col1 = ? and col2 = ? and col3 = ?
Rows in table: 5776
Threshold: 100
Rows returned above threshold, skipping dpan generation batch file.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.125 s
[INFO] Finished at: 2016-02-08T09:31:37-08:00
[INFO] Final Memory: 8M/245M
...
In the Jenkins job, I create a Post Build step, and put the following line in Default Content:
${BUILD_LOG_EXCERPT, start="\\b(Parameters)\\b", end="\\b(Threshold)\\b"}
When I trigger the job, all i get is an empty email. However if I add
${BUILD_LOG, maxLines=9999, escapeHtml=false}
then i get the full console output in the email. Any ideas? I am using version 2.40.3 of the plugin.
Looks like your regex is failing to find any matches, so you aren't getting any lines of the log. This is because the BUILD_LOG_EXCERPT
variable uses java.util.regex.Pattern.Matcher.matches()
to match a regex - and this will only return True
if the entire string matches (referenced in this SO question). The log parser is running line-by-line, so it's testing your entire line against your regex and failing (since there are characters after "Parameters").
If you're looking for a string that starts with Parameters
but may have characters after it, you can match to
"\\b(Parameters)\\b(?s).*"
which will match "Parameters" and any arbitrary string after it.
BUILD_LOG_EXCERPT in email-ext follows a very simple regex match using start and end. got it working by using two echo statements i.e one at the start from where i wanted the piece of console log and one at the end position of the log you wanted in email.
example :
In Build step :
echo Start
<your build commands>
echo End
In Default section of email-ext use the below line to get it working :
${BUILD_LOG_EXCERPT, start="^Start", end="^End"}
if your using a html email output you can use below line to align output in email
<pre>${BUILD_LOG_EXCERPT, start="^Start", end="^End"}</pre>
you can tweak and get it working , Hope it works for you as it did for me .
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With