{"id":430,"date":"2015-09-11T16:29:12","date_gmt":"2015-09-11T16:29:12","guid":{"rendered":"http:\/\/www.scmgalaxy.com\/tutorials\/2015\/09\/11\/how-to-attach-the-jenkins-build-log-as-part-of-the-email-body\/"},"modified":"2021-11-19T06:59:55","modified_gmt":"2021-11-19T06:59:55","slug":"how-to-attach-the-jenkins-build-log-as-part-of-the-email-body","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/how-to-attach-the-jenkins-build-log-as-part-of-the-email-body\/","title":{"rendered":"How to attach the jenkins build log as part of the email body?"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3363 aligncenter\" src=\"http:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2015\/09\/jenkins-build-log-as-part-o.png\" alt=\"jenkins-build-log-as-part-of-the-email-body\" width=\"600\" height=\"400\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2015\/09\/jenkins-build-log-as-part-o.png 600w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2015\/09\/jenkins-build-log-as-part-o-300x200.png 300w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/p>\n<p><strong>Way 1 &#8211;&nbsp;<\/strong><\/p>\n<p>Put following lines as part of Default Content text box<\/p>\n<p>${BUILD_LOG, maxLines=9999, escapeHtml=false}<\/p>\n<p>this works for free style projects<\/p>\n<p><strong>Way 2 &#8211; If you want send only specific line using regex<\/strong><\/p>\n<p>${BUILD_LOG_REGEX, regex=&#8221;\\\\b(Buildfile|BUILD)\\\\b&#8221;, linesAfter=1}<\/p>\n<p>${BUILD_LOG_REGEX, regex=&#8221;^.*?BUILD FAILED.*?$&#8221;, linesBefore=0, linesAfter=10, maxMatches=5, showTruncatedLines=false, escapeHtml=true}<\/p>\n<p>${BUILD_LOG_REGEX, regex=&#8221;\\\\b(FC0)\\\\b&#8221;, linesAfter=1}<\/p>\n<p>${BUILD_LOG_REGEX, regex=&#8221;^.*?BUILD FAILED.*?$&#8221;, linesBefore=0, linesAfter=10, maxMatches=5, showTruncatedLines=false, escapeHtml=true}<\/p>\n<p>${BUILD_LOG_REGEX, regex=&#8221;^.*?FC0.*?$&#8221;, maxMatches=95, showTruncatedLines=false, escapeHtml=false, matchedLineHtmlStyle=true}<\/p>\n<p>This will show exactly which is expected lines as part of the regEx.<\/p>\n<p>More Info<\/p>\n<p><a href=\"http:\/\/wiki.hudson-ci.org\/display\/HUDSON\/Email-ext+plugin\" target=\"_blank\" rel=\"noopener\">http:\/\/wiki.hudson-ci.org\/display\/HUDSON\/Email-ext+plugin<\/a><\/p>\n<p><a href=\"http:\/\/stackoverflow.com\/questions\/9439450\/how-will-i-filter-out-only-errors-in-jenkins-email-ext-build-log-regex\" target=\"_blank\" rel=\"noopener\">http:\/\/stackoverflow.com\/questions\/9439450\/how-will-i-filter-out-only-errors-in-jenkins-email-ext-build-log-regex<\/a><\/p>\n<p><a href=\"http:\/\/champasoft.blogspot.nl\/2012\/11\/jenkins-pattern-for-e-mailing-log.html\" target=\"_blank\" rel=\"noopener\">http:\/\/champasoft.blogspot.nl\/2012\/11\/jenkins-pattern-for-e-mailing-log.html<\/a><\/p>\n\n<div class=\"epyt-gallery\" data-currpage=\"1\" id=\"epyt_gallery_39279\"><figure class=\"wp-block-embed wp-block-embed-youtube is-type-video is-provider-youtube epyt-figure\"><div class=\"wp-block-embed__wrapper\"><iframe loading=\"lazy\"  id=\"_ytid_34899\"  width=\"760\" height=\"427\"  data-origwidth=\"760\" data-origheight=\"427\" src=\"https:\/\/www.youtube.com\/embed\/?enablejsapi=1&#038;autoplay=0&#038;cc_load_policy=0&#038;cc_lang_pref=&#038;iv_load_policy=1&#038;loop=0&#038;rel=1&#038;fs=1&#038;playsinline=0&#038;autohide=2&#038;theme=dark&#038;color=red&#038;controls=1&#038;disablekb=0&#038;\" class=\"__youtube_prefs__  no-lazyload\" title=\"YouTube player\"  data-epytgalleryid=\"epyt_gallery_39279\"  allow=\"fullscreen; accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen data-no-lazy=\"1\" data-skipgform_ajax_framebjll=\"\"><\/iframe><\/div><\/figure><div class=\"epyt-gallery-list\"><div>Sorry, there was a YouTube error.<\/div><\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>Way 1 &#8211;&nbsp; Put following lines as part of Default Content text box ${BUILD_LOG, maxLines=9999, escapeHtml=false} this works for free style projects Way 2 &#8211; If you want send only specific line using regex ${BUILD_LOG_REGEX, regex=&#8221;\\\\b(Buildfile|BUILD)\\\\b&#8221;, linesAfter=1} ${BUILD_LOG_REGEX, regex=&#8221;^.*?BUILD FAILED.*?$&#8221;, linesBefore=0, linesAfter=10, maxMatches=5, showTruncatedLines=false, escapeHtml=true} ${BUILD_LOG_REGEX, regex=&#8221;\\\\b(FC0)\\\\b&#8221;, linesAfter=1} ${BUILD_LOG_REGEX, regex=&#8221;^.*?BUILD FAILED.*?$&#8221;, linesBefore=0, linesAfter=10, maxMatches=5, showTruncatedLines=false,&#8230;<\/p>\n","protected":false},"author":1,"featured_media":3363,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","_joinchat":[],"footnotes":""},"categories":[42],"tags":[1449,91,473,1451,1122,545,1454,145,1453,1455,984,1450,593,732,104,1452],"class_list":["post-430","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-jenkins","tag-attach","tag-build","tag-email","tag-email-body","tag-guide","tag-how","tag-how-to-attach-jenkins-build-log","tag-jenkins","tag-jenkins-build-log","tag-jenkins-build-log-in-email-body","tag-log","tag-part","tag-process","tag-steps","tag-tutorials","tag-ways"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/430","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=430"}],"version-history":[{"count":2,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/430\/revisions"}],"predecessor-version":[{"id":25809,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/430\/revisions\/25809"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media\/3363"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=430"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=430"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=430"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}