{"id":195,"date":"2020-01-29T12:08:36","date_gmt":"2020-01-29T06:38:36","guid":{"rendered":"http:\/\/blogs.shydrate.com\/?p=195"},"modified":"2020-01-29T12:08:39","modified_gmt":"2020-01-29T06:38:39","slug":"running-python-scripts-in-jenkins","status":"publish","type":"post","link":"http:\/\/blogs.shydrate.com\/index.php\/2020\/01\/29\/running-python-scripts-in-jenkins\/","title":{"rendered":"Running Python scripts in Jenkins"},"content":{"rendered":"\n<p>In this post, I will show how to run python scripts in Jenkins. For demo purpose, I have installed python and Jenkins in my local system.<\/p>\n\n\n\n<p>Make sure you have installed the latest version of Jenkins and Python in your system(local or cloud). I assume that you have already done setup of Jenkins in your system.<\/p>\n\n\n\n<p>Now navigate to Global Tool Configuration which is under manage Jenkins. Scroll down and click on add Python under python. <img loading=\"lazy\" decoding=\"async\" width=\"1536\" height=\"692\" class=\"wp-image-196\" style=\"width: 600px\" src=\"http:\/\/blogs.shydrate.com\/wp-content\/uploads\/2020\/01\/1.png\" alt=\"\" srcset=\"http:\/\/blogs.shydrate.com\/wp-content\/uploads\/2020\/01\/1.png 1536w, http:\/\/blogs.shydrate.com\/wp-content\/uploads\/2020\/01\/1-300x135.png 300w, http:\/\/blogs.shydrate.com\/wp-content\/uploads\/2020\/01\/1-1024x461.png 1024w, http:\/\/blogs.shydrate.com\/wp-content\/uploads\/2020\/01\/1-768x346.png 768w\" sizes=\"auto, (max-width: 1536px) 100vw, 1536px\" \/><\/p>\n\n\n\n<p>Give the path of python installed location here and save it.<\/p>\n\n\n\n<p>Now go Jenkins job and create a new job. Select the freestyle project.<\/p>\n\n\n\n<p>Under SCM select your git repository. And add your git URL. <a href=\"https:\/\/github.com\/shydrate\/Test_python\">My repo<\/a><\/p>\n\n\n\n<p>Underbuild section select Execute Windows batch command. And add the below command to set python path &#8220;SET PATH=%PATH%;%Python_path%&#8221;.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1106\" height=\"584\" src=\"http:\/\/blogs.shydrate.com\/wp-content\/uploads\/2020\/01\/1_1.png\" alt=\"\" class=\"wp-image-198\" srcset=\"http:\/\/blogs.shydrate.com\/wp-content\/uploads\/2020\/01\/1_1.png 1106w, http:\/\/blogs.shydrate.com\/wp-content\/uploads\/2020\/01\/1_1-300x158.png 300w, http:\/\/blogs.shydrate.com\/wp-content\/uploads\/2020\/01\/1_1-1024x541.png 1024w, http:\/\/blogs.shydrate.com\/wp-content\/uploads\/2020\/01\/1_1-768x406.png 768w\" sizes=\"auto, (max-width: 1106px) 100vw, 1106px\" \/><\/figure>\n\n\n\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1118\" height=\"452\" class=\"wp-image-199\" style=\"width: 600px\" src=\"http:\/\/blogs.shydrate.com\/wp-content\/uploads\/2020\/01\/1_2.png\" alt=\"\" srcset=\"http:\/\/blogs.shydrate.com\/wp-content\/uploads\/2020\/01\/1_2.png 1118w, http:\/\/blogs.shydrate.com\/wp-content\/uploads\/2020\/01\/1_2-300x121.png 300w, http:\/\/blogs.shydrate.com\/wp-content\/uploads\/2020\/01\/1_2-1024x414.png 1024w, http:\/\/blogs.shydrate.com\/wp-content\/uploads\/2020\/01\/1_2-768x310.png 768w\" sizes=\"auto, (max-width: 1118px) 100vw, 1118px\" \/><\/p>\n\n\n\n<p>Python_path is variable, I have set this in Global properties under environment variable. Change it with your path.<img loading=\"lazy\" decoding=\"async\" width=\"1593\" height=\"444\" class=\"wp-image-197\" style=\"width: 600px\" src=\"http:\/\/blogs.shydrate.com\/wp-content\/uploads\/2020\/01\/5.png\" alt=\"\" srcset=\"http:\/\/blogs.shydrate.com\/wp-content\/uploads\/2020\/01\/5.png 1593w, http:\/\/blogs.shydrate.com\/wp-content\/uploads\/2020\/01\/5-300x84.png 300w, http:\/\/blogs.shydrate.com\/wp-content\/uploads\/2020\/01\/5-1024x285.png 1024w, http:\/\/blogs.shydrate.com\/wp-content\/uploads\/2020\/01\/5-768x214.png 768w, http:\/\/blogs.shydrate.com\/wp-content\/uploads\/2020\/01\/5-1536x428.png 1536w\" sizes=\"auto, (max-width: 1593px) 100vw, 1593px\" \/><\/p>\n\n\n\n<p>And now add python command to run the file i.e, &#8220;python Trial.py&#8221;.Save it and click on a Build job.<\/p>\n\n\n\n<p>The project will get executed and you can check the console log.<\/p>\n\n\n\n<p>Hope this information has helped you.<img loading=\"lazy\" decoding=\"async\" width=\"782\" height=\"538\" class=\"wp-image-200\" style=\"width: 600px\" src=\"http:\/\/blogs.shydrate.com\/wp-content\/uploads\/2020\/01\/1_3.png\" alt=\"\" srcset=\"http:\/\/blogs.shydrate.com\/wp-content\/uploads\/2020\/01\/1_3.png 782w, http:\/\/blogs.shydrate.com\/wp-content\/uploads\/2020\/01\/1_3-300x206.png 300w, http:\/\/blogs.shydrate.com\/wp-content\/uploads\/2020\/01\/1_3-768x528.png 768w\" sizes=\"auto, (max-width: 782px) 100vw, 782px\" \/><\/p>\n<!-- AddThis Advanced Settings generic via filter on the_content --><!-- AddThis Share Buttons generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"<p>In this post, I will show how to run python scripts in Jenkins. For demo purpose, I have installed python and Jenkins in my local system. Make sure you have installed the latest version of Jenkins and Python in your<!-- AddThis Advanced Settings generic via filter on get_the_excerpt --><!-- AddThis Share Buttons generic via filter on get_the_excerpt --><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[39],"class_list":["post-195","post","type-post","status-publish","format-standard","hentry","category-my-articles","tag-pythondevopsjenkinsscriptsintegration"],"_links":{"self":[{"href":"http:\/\/blogs.shydrate.com\/index.php\/wp-json\/wp\/v2\/posts\/195","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/blogs.shydrate.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blogs.shydrate.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blogs.shydrate.com\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/blogs.shydrate.com\/index.php\/wp-json\/wp\/v2\/comments?post=195"}],"version-history":[{"count":2,"href":"http:\/\/blogs.shydrate.com\/index.php\/wp-json\/wp\/v2\/posts\/195\/revisions"}],"predecessor-version":[{"id":202,"href":"http:\/\/blogs.shydrate.com\/index.php\/wp-json\/wp\/v2\/posts\/195\/revisions\/202"}],"wp:attachment":[{"href":"http:\/\/blogs.shydrate.com\/index.php\/wp-json\/wp\/v2\/media?parent=195"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blogs.shydrate.com\/index.php\/wp-json\/wp\/v2\/categories?post=195"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blogs.shydrate.com\/index.php\/wp-json\/wp\/v2\/tags?post=195"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}