{"id":17924,"date":"2015-03-13T12:57:06","date_gmt":"2015-03-13T07:27:06","guid":{"rendered":"http:\/\/www.tothenew.com\/blog\/?p=17924"},"modified":"2015-03-23T17:38:38","modified_gmt":"2015-03-23T12:08:38","slug":"building-parameterized-script-in-jenkins","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/building-parameterized-script-in-jenkins\/","title":{"rendered":"Building Parameterized Script in Jenkins"},"content":{"rendered":"<p>Jenkins is an extensible open source continuous integration server. Using Jenkins we can perform the tasks automatically from our server or localhost. A script is created and built just once . Then, you can run the script by just clicking on <strong>Build<\/strong>\u00a0link<strong>\u00a0<\/strong>in Jenkins. The scripts can be scheduled using Jenkins. You can visit the following link: <a href=\"https:\/\/wiki.jenkins-ci.org\/display\/JENKINS\/Installing+Jenkins+on+Ubuntu\">Installation Steps of Jenkins<\/a> to check out the installation steps. In this blog, it will be explained that how to\u00a0<strong><em>BUILD PARAMETERIZED SCRIPT IN JENKINS.<\/em><\/strong><\/p>\n<p>The complete steps have been detailed below:<\/p>\n<ul>\n<li>Go to the Jenkins console by going to your localhost or the platform at which you install it.<\/li>\n<li>The screen will appear as shown below:<\/li>\n<\/ul>\n<p><\/br><\/p>\n<p><a href=\"\/blog\/wp-ttn-blog\/uploads\/2015\/03\/Selection_016.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-17926\" src=\"\/blog\/wp-ttn-blog\/uploads\/2015\/03\/Selection_016.png\" alt=\"Selection_016\" width=\"816\" height=\"444\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<ul>\n<li>Click on\u00a0<strong>New Item\u00a0<\/strong>link on the left pane. The new console will appear as shown below.<\/li>\n<\/ul>\n<p><a href=\"\/blog\/wp-ttn-blog\/uploads\/2015\/03\/Selection_017.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-17927\" src=\"\/blog\/wp-ttn-blog\/uploads\/2015\/03\/Selection_017.png\" alt=\"Selection_017\" width=\"1344\" height=\"372\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<ul>\n<li>Give the\u00a0<strong>Item Name\u00a0<\/strong>to your job and choose a project. I have chosen\u00a0<strong>Freestyle Project\u00a0<\/strong>here. After entering the details, click on\u00a0<strong>OK\u00a0<\/strong>button. The new console will appear as shown below.<\/li>\n<\/ul>\n<p><a href=\"\/blog\/wp-ttn-blog\/uploads\/2015\/03\/Selection_018.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-17928\" src=\"\/blog\/wp-ttn-blog\/uploads\/2015\/03\/Selection_018.png\" alt=\"Selection_018\" width=\"710\" height=\"412\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<ul>\n<li>Enter the adequate details above and then check the option &#8220;<strong>This build is parameterized.&#8221;\u00a0<\/strong>New options will then open up. You can choose any type of parameters that you wish to give during build. \u00a0Here I&#8217;m choosing <span style=\"color: #000000\"><b>String Parameter\u00a0<\/b> to show an example.<\/span>\u00a0<a href=\"\/blog\/wp-ttn-blog\/uploads\/2015\/03\/Selection_025.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-17935\" src=\"\/blog\/wp-ttn-blog\/uploads\/2015\/03\/Selection_025.png\" alt=\"Selection_025\" width=\"976\" height=\"420\" \/><\/a><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<ul>\n<li>Give a name to your String parameter. You can add any number of parameters you want. In this example, i have taken two string parameters- <strong>Name <\/strong>and\u00a0<strong>Practice.\u00a0<\/strong>Now during the build it will ask for the two parameters and then use these parameters. Now\u00a0click on\u00a0<strong>Apply.\u00a0<\/strong>Now choose <span style=\"color: #000000\"><b>Add build Step\u00a0<\/b>and then choose\u00a0<strong>Execute shell. \u00a0<\/strong>Enter your script in the textbox provided. I have entered the bash script to print Name and Practice. Click on Apply and Save.<\/span><\/li>\n<\/ul>\n<p><a href=\"\/blog\/wp-ttn-blog\/uploads\/2015\/03\/Selection_019.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-17930\" src=\"\/blog\/wp-ttn-blog\/uploads\/2015\/03\/Selection_019.png\" alt=\"Selection_019\" width=\"832\" height=\"247\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<ul>\n<li>Now you will get the option of <span style=\"color: #000000\"><b>Build with Parameters\u00a0<\/b>instead of\u00a0<strong>Build.\u00a0<\/strong>Click on the link and enter the parameters.<\/span><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p><a href=\"\/blog\/wp-ttn-blog\/uploads\/2015\/03\/Selection_020.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-17931\" src=\"\/blog\/wp-ttn-blog\/uploads\/2015\/03\/Selection_020.png\" alt=\"Selection_020\" width=\"360\" height=\"240\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<ul>\n<li>Enter the parameters in the textbox specified.<a href=\"\/blog\/wp-ttn-blog\/uploads\/2015\/03\/Selection_026.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-17936\" src=\"\/blog\/wp-ttn-blog\/uploads\/2015\/03\/Selection_026.png\" alt=\"Selection_026\" width=\"1011\" height=\"276\" \/><\/a><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul>\n<li>After entering the parameters click on\u00a0<strong>Build .\u00a0<\/strong>Your Job has been successfully built. Now go to your build and click on Console.<\/li>\n<\/ul>\n<p><a href=\"\/blog\/wp-ttn-blog\/uploads\/2015\/03\/Selection_023.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-17932\" src=\"\/blog\/wp-ttn-blog\/uploads\/2015\/03\/Selection_022.png\" alt=\"Selection_022\" width=\"351\" height=\"139\" \/><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-17933\" src=\"\/blog\/wp-ttn-blog\/uploads\/2015\/03\/Selection_023.png\" alt=\"Selection_023\" width=\"894\" height=\"283\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>The script has been executed successfully and the parameters that you entered are shown in the\u00a0<strong>Console Output.<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Jenkins is an extensible open source continuous integration server. Using Jenkins we can perform the tasks automatically from our server or localhost. A script is created and built just once . Then, you can run the script by just clicking on Build\u00a0link\u00a0in Jenkins. The scripts can be scheduled using Jenkins. You can visit the following [&hellip;]<\/p>\n","protected":false},"author":163,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":16},"categories":[1174],"tags":[248,1683,1685,1686,1682,1684,1687],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/17924"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/163"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=17924"}],"version-history":[{"count":0,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/17924\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=17924"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=17924"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=17924"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}