{"id":437,"date":"2015-10-03T12:26:05","date_gmt":"2015-10-03T12:26:05","guid":{"rendered":"http:\/\/www.scmgalaxy.com\/tutorials\/2015\/10\/03\/how-to-attach-the-jenkins-build-log-as-part-of-the-email-body-2\/"},"modified":"2021-11-19T06:47:33","modified_gmt":"2021-11-19T06:47:33","slug":"how-to-attach-the-jenkins-build-log-as-part-of-the-email-body-2","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/how-to-attach-the-jenkins-build-log-as-part-of-the-email-body-2\/","title":{"rendered":"How to attach the jenkins build log as part of the email body?"},"content":{"rendered":"<div><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3333 aligncenter\" src=\"http:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2015\/10\/jenkins-build-log-as-part-o-1.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\/10\/jenkins-build-log-as-part-o-1.png 600w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2015\/10\/jenkins-build-log-as-part-o-1-300x200.png 300w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/div>\n<div style=\"font-family: Calibri, sans-serif; font-size: 14px;\"><strong>Way 1 &#8211;&nbsp;<\/strong><\/div>\n<div style=\"font-family: Calibri, sans-serif; font-size: 14px;\"><\/div>\n<div style=\"font-family: Calibri, sans-serif; font-size: 14px;\">Put following lines as part of Default Content text box<\/div>\n<div style=\"font-family: Calibri, sans-serif; font-size: 14px;\">${BUILD_LOG, maxLines=9999, escapeHtml=false}<\/div>\n<div style=\"font-family: Calibri, sans-serif; font-size: 14px;\"><\/div>\n<div style=\"font-family: Calibri, sans-serif; font-size: 14px;\">this works for free style projects<\/div>\n<div style=\"font-family: Calibri, sans-serif; font-size: 14px;\"><\/div>\n<div style=\"font-family: Calibri, sans-serif; font-size: 14px;\"><strong>Way 2 &#8211; If you want send only specific line using regex<\/strong><\/div>\n<div style=\"font-family: Calibri, sans-serif; font-size: 14px;\">${BUILD_LOG_REGEX, regex=&#8221;\\\\b(Buildfile|BUILD)\\\\<wbr>b&#8221;, linesAfter=1}<\/div>\n<div style=\"font-family: Calibri, sans-serif; font-size: 14px;\"><\/div>\n<div style=\"font-family: Calibri, sans-serif; font-size: 14px;\">${BUILD_LOG_REGEX, regex=&#8221;^.*?BUILD FAILED.*?$&#8221;, linesBefore=0, linesAfter=10, maxMatches=5, showTruncatedLines=false, escapeHtml=true}<\/div>\n<div style=\"font-family: Calibri, sans-serif; font-size: 14px;\"><\/div>\n<div style=\"font-family: Calibri, sans-serif; font-size: 14px;\">${BUILD_LOG_REGEX, regex=&#8221;\\\\b(FC0)\\\\b&#8221;, linesAfter=1}<\/div>\n<div style=\"font-family: Calibri, sans-serif; font-size: 14px;\"><\/div>\n<div style=\"font-family: Calibri, sans-serif; font-size: 14px;\">${BUILD_LOG_REGEX, regex=&#8221;^.*?BUILD FAILED.*?$&#8221;, linesBefore=0, linesAfter=10, maxMatches=5, showTruncatedLines=false, escapeHtml=true}<\/div>\n<div style=\"font-family: Calibri, sans-serif; font-size: 14px;\"><\/div>\n<div style=\"font-family: Calibri, sans-serif; font-size: 14px;\">${BUILD_LOG_REGEX, regex=&#8221;^.*?FC0.*?$&#8221;, maxMatches=95, showTruncatedLines=false, escapeHtml=false, matchedLineHtmlStyle=true}<\/div>\n<div style=\"font-family: Calibri, sans-serif; font-size: 14px;\">This will show exactly which is expected lines as part of the regEx.<\/div>\n<div style=\"font-family: Calibri, sans-serif; font-size: 14px;\"><\/div>\n<div style=\"font-family: Calibri, sans-serif; font-size: 14px;\"><strong>List of other variables as part of email body<\/strong><\/div>\n<div style=\"font-family: Calibri, sans-serif; font-size: 14px;\">${PROJECT_URL}\/ws\/<\/div>\n<div style=\"font-family: Calibri, sans-serif; font-size: 14px;\">${BUILD_URL}\/artifact\/<\/div>\n<div style=\"font-family: Calibri, sans-serif; font-size: 14px;\">${BUILD_LOG, maxLines=1000}<\/div>\n<div style=\"font-family: Calibri, sans-serif; font-size: 14px;\"><\/div>\n<div style=\"font-family: Calibri, sans-serif; font-size: 14px;\">More ref<\/div>\n<div style=\"font-family: Calibri, sans-serif; font-size: 14px;\">Content Token Reference<\/div>\n<div style=\"font-family: Calibri, sans-serif; font-size: 14px;\"><\/div>\n<div style=\"font-family: Calibri, sans-serif; font-size: 14px;\">In string arguments, escape &#8220;, \\, and line terminators (\\n or \\r\\n) with a \\, e.g. arg1=&#8221;\\&#8221;quoted\\&#8221;&#8221;; arg2=&#8221;c:\\\\path&#8221;; and arg3=&#8221;one\\ntwo&#8221;. The brackets may be omitted if there are no arguments.<\/div>\n<div style=\"font-family: Calibri, sans-serif; font-size: 14px;\"><\/div>\n<div style=\"font-family: Calibri, sans-serif; font-size: 14px;\">New Lines &#8211; Use &lt;br&gt; or &#8220;\\&#8221;<\/div>\n<div style=\"font-family: Calibri, sans-serif; font-size: 14px;\"><\/div>\n<div style=\"font-family: Calibri, sans-serif; font-size: 14px;\"><strong>More Info&nbsp;<\/strong><\/div>\n<div style=\"font-family: Calibri, sans-serif; font-size: 14px;\"><a style=\"color: #1155cc;\" href=\"http:\/\/wiki.hudson-ci.org\/display\/HUDSON\/Email-ext+plugin\" target=\"_blank\" rel=\"noopener\">http:\/\/wiki.hudson-ci.org\/<wbr>display\/HUDSON\/Email-ext+<wbr>plugin<\/a><\/div>\n<div style=\"font-family: Calibri, sans-serif; font-size: 14px;\"><a style=\"color: #1155cc;\" 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\/<wbr>questions\/9439450\/how-will-i-<wbr>filter-out-only-errors-in-<wbr>jenkins-email-ext-build-log-<wbr>regex<\/a><\/div>\n<div style=\"font-family: Calibri, sans-serif; font-size: 14px;\"><a style=\"color: #1155cc;\" href=\"http:\/\/champasoft.blogspot.nl\/2012\/11\/jenkins-pattern-for-e-mailing-log.html\" target=\"_blank\" rel=\"noopener\">http:\/\/champasoft.blogspot.nl\/<wbr>2012\/11\/jenkins-pattern-for-e-<wbr>mailing-log.html<\/a><\/div>\n<div style=\"font-family: Calibri, sans-serif; font-size: 14px;\"><a style=\"color: #1155cc;\" href=\"https:\/\/wiki.jenkins-ci.org\/display\/JENKINS\/Email-ext+plugin\" target=\"_blank\" rel=\"noopener\">https:\/\/wiki.jenkins-ci.org\/<wbr>display\/JENKINS\/Email-ext+<wbr>plugin<\/a><\/div>\n\n<div class=\"epyt-gallery\" data-currpage=\"1\" id=\"epyt_gallery_65546\"><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_69389\"  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_65546\"  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":3332,"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,1451,1122,545,1454,145,1453,1455,984,1450,593,732,104,1452],"class_list":["post-437","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-jenkins","tag-attach","tag-build","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\/437","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=437"}],"version-history":[{"count":2,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/437\/revisions"}],"predecessor-version":[{"id":25801,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/437\/revisions\/25801"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media\/3332"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=437"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=437"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=437"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}