I am building Jenkins pipeline scripts and sending email on build status.
stage('Sending email') {
echo "${FINAL_EAR}"
emailext body: '''$DEFAULT_CONTENT
The cause of the build:
${BUILD_CAUSE}
current build changes:
${CHANGES, showPaths=true, format="%a: %r %p \\n--\\"%m\\"", pathFormat="\\n\\t- %p"}
Changes since the last build:
${CHANGES_SINCE_LAST_UNSTABLE}
Artifact location:
${BUILD_LOG_REGEX, regex="^`\\\\$\\\\{FINAL_EAR\\\\}' ->", showTruncatedLines=false}''', replyTo: '$DEFAULT_REPLYTO', subject: '$DEFAULT_SUBJECT', to: 'blah@blah.com'
}
In above snippet I am facing issue with regex="^`\\$\\{FINAL_EAR\\}' ->". Regex is unable to match the correct value, echo prints value correct. I tried escaping (with or without) $, { and } which has special meaning in regex, still it won't work.
This is the error I see once I receive email "java.util.regex.PatternSyntaxException: Illegal repetition near index 1 ^${FINAL_EAR}' -> ^"
Note: The actual log contains with `, ' and -> so I need those characters in regex. Appreciate your help in advance.
I don't say I got the answer but rather looking for exact "${FINAL_EAR} ->" I used regex as below
${BUILD_LOG_REGEX, regex="^`[a-zA-Z0-9-.]*' ->", showTruncatedLines=false}''', replyTo: '$DEFAULT_REPLYTO', subject: '$DEFAULT_SUBJECT', to: 'blah@blah.com'
I don't want to leave this unanswered so wanted to provide the way I implemented.