{"id":1676,"date":"2019-06-28T14:24:07","date_gmt":"2019-06-28T14:24:07","guid":{"rendered":"http:\/\/robermb.com\/blog\/?p=1676"},"modified":"2020-12-17T22:07:31","modified_gmt":"2020-12-17T21:07:31","slug":"colorize-your-jenkins-output","status":"publish","type":"post","link":"https:\/\/robermb.com\/blog\/geeks\/colorize-your-jenkins-output\/","title":{"rendered":"Colorize your Jenkins output"},"content":{"rendered":"\n<p>There is a <strong>plugin<\/strong> in Jenkins very useful to make your life easier when you need to <strong>review the console output<\/strong> after a job execution. <\/p>\n\n\n\n<p>This plugin allow you to see the errors and the entire output with colors(<strong>red<\/strong> for errors, <strong>green<\/strong> for good results, etc). It&#8217;s really useful.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Install the plugin<\/h3>\n\n\n\n<p>Firstable we need to install in Jenkins the plugin called <strong>AnsiColor<\/strong>:<\/p>\n\n\n\n<p>Go to <strong>Manage Jenkins<\/strong> &#8211;&gt; <strong>Manage Plugins<\/strong> &#8211;&gt; <strong>Available<\/strong> &#8211;&gt; <strong>AnsiColor<\/strong><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>Install it and then restart Jenkins.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Configure a Job to use the plugin<\/h3>\n\n\n\n<p> In my example I will configure a Job which execute a playbook in Ansible.<\/p>\n\n\n\n<p>Go to the job to change some configurations that enables the ability of the plugin to show colors in the output.<\/p>\n\n\n\n<p>Select the <strong>Job<\/strong> &#8211;&gt; <strong>Configure<\/strong><\/p>\n\n\n\n<p>In <strong>General<\/strong> tab, <strong>Build Environment<\/strong> section we have to enable <strong>Color ANSI Console Output<\/strong>. Leave the other options by default.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"368\" height=\"224\" src=\"http:\/\/robermb.com\/blog\/wp-content\/uploads\/2019\/06\/enable_ansicolor_1.png\" alt=\"\" class=\"wp-image-1678\" srcset=\"https:\/\/robermb.com\/blog\/wp-content\/uploads\/2019\/06\/enable_ansicolor_1.png 368w, https:\/\/robermb.com\/blog\/wp-content\/uploads\/2019\/06\/enable_ansicolor_1-300x183.png 300w, https:\/\/robermb.com\/blog\/wp-content\/uploads\/2019\/06\/enable_ansicolor_1-150x91.png 150w\" sizes=\"(max-width: 368px) 100vw, 368px\" \/><\/figure>\n\n\n\n<p>Then in <strong>Build<\/strong> section where we are invoking our ansible playbooks we have to <strong>enable<\/strong> <strong>Colorized stdout<\/strong> option after clicking on Advanced&#8230; button.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"258\" height=\"34\" src=\"http:\/\/robermb.com\/blog\/wp-content\/uploads\/2019\/06\/enable_ansicolor_2.png\" alt=\"\" class=\"wp-image-1679\" srcset=\"https:\/\/robermb.com\/blog\/wp-content\/uploads\/2019\/06\/enable_ansicolor_2.png 258w, https:\/\/robermb.com\/blog\/wp-content\/uploads\/2019\/06\/enable_ansicolor_2-150x20.png 150w\" sizes=\"(max-width: 258px) 100vw, 258px\" \/><\/figure>\n\n\n\n<p>And this is the result after executing a job:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"889\" height=\"454\" src=\"http:\/\/robermb.com\/blog\/wp-content\/uploads\/2019\/06\/enable_ansicolor_result.png\" alt=\"\" class=\"wp-image-1680\" srcset=\"https:\/\/robermb.com\/blog\/wp-content\/uploads\/2019\/06\/enable_ansicolor_result.png 889w, https:\/\/robermb.com\/blog\/wp-content\/uploads\/2019\/06\/enable_ansicolor_result-300x153.png 300w, https:\/\/robermb.com\/blog\/wp-content\/uploads\/2019\/06\/enable_ansicolor_result-150x77.png 150w\" sizes=\"(max-width: 889px) 100vw, 889px\" \/><\/figure>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>Link: <\/p>\n\n\n\n<p><a href=\"http:\/\/wiki.jenkins-ci.org\/display\/JENKINS\/AnsiColor+Plugin\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\">http:\/\/wiki.jenkins-ci.org\/display\/JENKINS\/AnsiColor+Plugin<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>There is a plugin in Jenkins very useful to make your life easier when you need to review the console &hellip; <a href=\"https:\/\/robermb.com\/blog\/geeks\/colorize-your-jenkins-output\/\" class=\"more-link\">More <span class=\"screen-reader-text\">Colorize your Jenkins output<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":1677,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[103,2],"tags":[106,104,102,105],"_links":{"self":[{"href":"https:\/\/robermb.com\/blog\/wp-json\/wp\/v2\/posts\/1676"}],"collection":[{"href":"https:\/\/robermb.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/robermb.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/robermb.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/robermb.com\/blog\/wp-json\/wp\/v2\/comments?post=1676"}],"version-history":[{"count":6,"href":"https:\/\/robermb.com\/blog\/wp-json\/wp\/v2\/posts\/1676\/revisions"}],"predecessor-version":[{"id":1810,"href":"https:\/\/robermb.com\/blog\/wp-json\/wp\/v2\/posts\/1676\/revisions\/1810"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/robermb.com\/blog\/wp-json\/wp\/v2\/media\/1677"}],"wp:attachment":[{"href":"https:\/\/robermb.com\/blog\/wp-json\/wp\/v2\/media?parent=1676"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/robermb.com\/blog\/wp-json\/wp\/v2\/categories?post=1676"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/robermb.com\/blog\/wp-json\/wp\/v2\/tags?post=1676"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}