I'm trying to get the version of the app from the jenkins log to send it to email.
The log (part of it) is:
[INFO] Image 03127cdb479b: Layer already exists
[INFO] Image 9c742cd6c7a5: Layer already exists
[INFO] Image 1f8a8b50f407: Pushing
[INFO] Image 1f8a8b50f407: Pushed
[INFO] 4.2.3-202211071000: digest: sha256:[large_number] size: 2415
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
I want only the 4.2.3-202211071000 part, so I'm doing:
${BUILD_LOG_REGEX, regex="(?<=\[INFO])(.*)(?=: digest)", maxMatches=1, showTruncatedLines=false, substText="$1"}
but this is returning the entire line:
[INFO] 4.2.3-202211071000: digest: sha256:[large_number] size: 2415
not only the text between "[INFO] " and ": digest". How can I do that?
CodePudding user response:
Try this pattern: (?<=\[INFO\] )[-\d\.] (?=:)
See here for a breakdown of the RegEx
CodePudding user response:
Check the following pattern.
regex="(\\[INFO\\] (.*): digest)"