{"id":2971,"date":"2023-01-15T19:27:08","date_gmt":"2023-01-15T19:27:08","guid":{"rendered":"https:\/\/devclouds.io\/blog\/?p=2971"},"modified":"2023-01-19T09:01:11","modified_gmt":"2023-01-19T09:01:11","slug":"configure-build-tools-in-jenkins","status":"publish","type":"post","link":"https:\/\/devclouds.io\/blog\/configure-build-tools-in-jenkins\/","title":{"rendered":"Configure Build Tools in Jenkins"},"content":{"rendered":"\n<p>I&#8217;m going to show you how to configure different build tools in Jenkins.<\/p>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img decoding=\"async\" src=\"https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_16-6-1024x529.jpg\" alt=\"Build tools\" class=\"wp-image-2972\" width=\"768\" height=\"397\" srcset=\"https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_16-6-1024x529.jpg 1024w, https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_16-6-300x155.jpg 300w, https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_16-6-768x397.jpg 768w, https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_16-6.jpg 1365w\" sizes=\"(max-width: 768px) 100vw, 768px\" \/><\/figure>\n<\/div>\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>So the development flow usually looks like this. Develop your application and now using Jenkins you want to build and package that application.<\/p>\n\n\n\n<p>In order to build the application in the package you need some kind of build tools. Depending on which technology which language you use. you are going to need a different build tool.<\/p>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img decoding=\"async\" src=\"https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_1-6-1024x575.jpg\" alt=\"4 Main Build Tools\" class=\"wp-image-2973\" width=\"768\" height=\"431\" srcset=\"https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_1-6-1024x575.jpg 1024w, https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_1-6-300x169.jpg 300w, https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_1-6-768x432.jpg 768w, https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_1-6.jpg 1365w\" sizes=\"(max-width: 768px) 100vw, 768px\" \/><\/figure>\n<\/div>\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>For example the four main tools that I&#8217;ve used commonly in projects and there some more but this four main are maven and Gradle for beckend applications. like if you&#8217;re developing your java application you probably use one of those. And if you have a JavaScript application then you are going to be using either NPM or yarn.<\/p>\n\n\n\n<p>For example if you have frontend in JavaScript you will build it using NPM or yarn and backend you will build it using maven or Gradle. You will need at least one of those build tools in your Jenkins build configuration.<\/p>\n\n\n\n<p>Because Jenkins build has to run these commands so how does it work how does Jenkins allow you to use these build tools. Some of these tools are available or installed in Jenkins out of the box. The rest of them you have to install as plugins and configure them.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-configure-build-tools-in-jenkins\">Configure Build Tools in Jenkins<\/h2>\n\n\n\n<p>The first step that you need to do is to go to the Jenkins configuration and check whether your tool is already there out of the box if it is. You just use it if not you go to the plugins you install it.<\/p>\n\n\n\n<p>Go back to the configuration and then you configure it. Once you have that already in a Jenkins configuration you can actually use it and the usage depends on what type of built of Jenkins use.<\/p>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img decoding=\"async\" src=\"https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_2-6-1024x575.jpg\" alt=\"Manage Jenkins\" class=\"wp-image-2974\" width=\"768\" height=\"431\" srcset=\"https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_2-6-1024x575.jpg 1024w, https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_2-6-300x169.jpg 300w, https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_2-6-768x432.jpg 768w, https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_2-6.jpg 1365w\" sizes=\"(max-width: 768px) 100vw, 768px\" \/><\/figure>\n<\/div>\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>I&#8217;m going to show you example of using two of these tools actually in Jenkins file. So let&#8217;s actually go to &#8220;manage Jenkins&#8221; and &#8220;global tool configuration&#8221; that&#8217;s where all the tools are configured.<\/p>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img decoding=\"async\" src=\"https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_3-5-1024x575.jpg\" alt=\"Gradle Maven\" class=\"wp-image-2976\" width=\"768\" height=\"431\" srcset=\"https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_3-5-1024x575.jpg 1024w, https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_3-5-300x169.jpg 300w, https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_3-5-768x432.jpg 768w, https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_3-5.jpg 1365w\" sizes=\"(max-width: 768px) 100vw, 768px\" \/><\/figure>\n<\/div>\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>Here you can see the list of the out of the box available tools so if I scroll here I see I have Gradle and I have maven. Which is already configured for me and I have docker. What I don&#8217;t have here is NPM or yarn.<\/p>\n\n\n\n<p>I&#8217;m gonna create an example Jenkins pipeline using a demo application that I have. And this demo application that I have uses Gradle and yarn to build backend and frontend respectively. Which means I don&#8217;t need the maven installation here I only need Gradle from here. In addition to that I will need yarn one.<\/p>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img decoding=\"async\" src=\"https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_4-5-1024x575.jpg\" alt=\"Maven Tool\" class=\"wp-image-2975\" width=\"768\" height=\"431\" srcset=\"https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_4-5-1024x575.jpg 1024w, https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_4-5-300x169.jpg 300w, https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_4-5-768x432.jpg 768w, https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_4-5.jpg 1365w\" sizes=\"(max-width: 768px) 100vw, 768px\" \/><\/figure>\n<\/div>\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>If I hover here in Maven installation of version 3.63 which is installed directly from Apache from internet. so how this configuration works.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Gradle Installations<\/h2>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img decoding=\"async\" src=\"https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_5-6-1024x575.jpg\" alt=\"Gradle Installation\" class=\"wp-image-2977\" width=\"768\" height=\"431\" srcset=\"https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_5-6-1024x575.jpg 1024w, https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_5-6-300x169.jpg 300w, https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_5-6-768x432.jpg 768w, https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_5-6.jpg 1365w\" sizes=\"(max-width: 768px) 100vw, 768px\" \/><\/figure>\n<\/div>\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>We can see it on Gradle example if I do add Gradle I just give it a name whenever I want. Here I choose the version actually I&#8217;m gonna go with the latest one.<\/p>\n\n\n\n<p>You can also fix it a different version if your project needs that. Jenkins will install that tool automatically for me. I don&#8217;t have to go and install that on a Jenkins server or whatever.<\/p>\n\n\n\n<p>Jenkins does automatically which is extremely convenient and this is basically the type of installer. so if you see here the button &#8220;installer&#8221; the options is installed from <a href=\"https:\/\/gradle.org\/\" target=\"_blank\" rel=\"noreferrer noopener\">Gradle.org<\/a>. which is what I have by default here so I&#8217;m gonna leave it at that and that&#8217;s it<\/p>\n\n\n\n<p>Gradle is configured I can use Gradle now in my Jenkinsfile so I can save it.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Install npm and yarn from plugins<\/h2>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img decoding=\"async\" src=\"https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_6-8-1024x408.jpg\" alt=\"npm yarn\" class=\"wp-image-2978\" width=\"768\" height=\"306\" srcset=\"https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_6-8-1024x408.jpg 1024w, https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_6-8-300x120.jpg 300w, https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_6-8-768x306.jpg 768w, https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_6-8.jpg 1141w\" sizes=\"(max-width: 768px) 100vw, 768px\" \/><\/figure>\n<\/div>\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>As I showed you I don&#8217;t have n npm or yarn installed.<\/p>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img decoding=\"async\" src=\"https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_7-9-1024x466.jpg\" alt=\"Manage Jenkins and available tools\" class=\"wp-image-2979\" width=\"768\" height=\"350\" srcset=\"https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_7-9-1024x466.jpg 1024w, https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_7-9-300x136.jpg 300w, https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_7-9-768x349.jpg 768w, https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_7-9.jpg 1365w\" sizes=\"(max-width: 768px) 100vw, 768px\" \/><\/figure>\n<\/div>\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>In order to do that I go to &#8220;manage plugins&#8221; go to &#8220;Available&#8221; there is a specific &#8220;npm plugin&#8221; as well and &#8220;npm pipeline plugin&#8221;. The way I do this is I&#8217;m gonna install in &#8220;nodeJS plugin&#8221; which will give me the &#8220;npm&#8221; as well.<\/p>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img decoding=\"async\" src=\"https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_8-8-1024x554.jpg\" alt=\"NodeJs Tools\" class=\"wp-image-2980\" width=\"768\" height=\"416\" srcset=\"https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_8-8-1024x554.jpg 1024w, https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_8-8-300x162.jpg 300w, https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_8-8-768x415.jpg 768w, https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_8-8.jpg 1365w\" sizes=\"(max-width: 768px) 100vw, 768px\" \/><\/figure>\n<\/div>\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>So I&#8217;m gonna install that after successful installation and I restart my Jenkins. Because you need to restart it so that the plugin changes take effect. Now if I go to &#8220;global tool configuration&#8221;.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">NodeJS Installation<\/h2>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img decoding=\"async\" src=\"https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_9-6-1024x552.jpg\" alt=\"NodeJs Configuration\" class=\"wp-image-2981\" width=\"768\" height=\"414\" srcset=\"https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_9-6-1024x552.jpg 1024w, https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_9-6-300x162.jpg 300w, https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_9-6-768x414.jpg 768w, https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_9-6.jpg 1365w\" sizes=\"(max-width: 768px) 100vw, 768px\" \/><\/figure>\n<\/div>\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>I should see the nodeJS in the list so I&#8217;m gonna add nodeJS. And the project that I&#8217;m actually works with the older nodeJS version. It has some backwards compatibility problem issues so I&#8217;m gonna fix a the nodeJS version to 10.17.0. So that&#8217;s the version that the application works on. Here the part where Jenkins automatically installing the nodeJS with this version.<\/p>\n\n\n\n<p>I&#8217;m gonna give it a name let&#8217;s call it node-10.17 there is a common practice to name the installation with the version because if you have multiple of them you want to differentiate between node 1 no 2 so you can do something like i did.<\/p>\n\n\n\n<p>You can make it to install global packages and yarn is one of the npm packages. So if I write a yarn here it&#8217;s gonna install that automatically. You can also fix its the version of NPM packages and I&#8217;m gonna need that as well. Because again my app doesn&#8217;t work with the latest yarn version. So I&#8217;m gonna fix that it like yarn@1.13.0. that&#8217;s a syntax for it.<\/p>\n\n\n\n<p>I&#8217;m gonna save that so now when I create a pipeline I should have both Gradle and yarn available.<\/p>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img decoding=\"async\" src=\"https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_10-7-1024x518.jpg\" alt=\"my demo project\" class=\"wp-image-2982\" width=\"768\" height=\"389\" srcset=\"https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_10-7-1024x518.jpg 1024w, https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_10-7-300x152.jpg 300w, https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_10-7-768x388.jpg 768w, https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_10-7.jpg 1365w\" sizes=\"(max-width: 768px) 100vw, 768px\" \/><\/figure>\n<\/div>\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>So I&#8217;m gonna create that pipeline it&#8217;s gonna be my-demo-project multibranch pipeline so that&#8217;s my repository.<\/p>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img decoding=\"async\" src=\"https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_11-7-1024x557.jpg\" alt=\"credentials\" class=\"wp-image-2983\" width=\"768\" height=\"418\" srcset=\"https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_11-7-1024x557.jpg 1024w, https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_11-7-300x163.jpg 300w, https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_11-7-768x417.jpg 768w, https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_11-7.jpg 1365w\" sizes=\"(max-width: 768px) 100vw, 768px\" \/><\/figure>\n<\/div>\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>I have the credentials already configured and I&#8217;m gonna build only master here. It&#8217;s gonna scan the project for master and the Jenkinsfile. and I don&#8217;t have a Jenkinsfile in the master branch. So let&#8217;s go and create some very super simple Jenkinsfile just to demonstrate the usage of these two tools.<\/p>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img decoding=\"async\" src=\"https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_12-7-1024x471.jpg\" alt=\"Github Jenkinsfile\" class=\"wp-image-2984\" width=\"768\" height=\"353\" srcset=\"https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_12-7-1024x471.jpg 1024w, https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_12-7-300x138.jpg 300w, https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_12-7-768x353.jpg 768w, https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_12-7.jpg 1365w\" sizes=\"(max-width: 768px) 100vw, 768px\" \/><\/figure>\n<\/div>\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>Here I&#8217;m gonna create a Jenkinsfile.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Configure Jenkinsfile to Build Tools in Jenkins<\/h2>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img decoding=\"async\" src=\"https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_13-6-1024x554.jpg\" alt=\"Jenkinsfile Syntax\" class=\"wp-image-2985\" width=\"768\" height=\"416\" srcset=\"https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_13-6-1024x554.jpg 1024w, https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_13-6-300x162.jpg 300w, https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_13-6-768x416.jpg 768w, https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_13-6.jpg 1365w\" sizes=\"(max-width: 768px) 100vw, 768px\" \/><\/figure>\n<\/div>\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>So this is a very basic pipeline syntax that has two stages we build frontend and we build the backend. The plan is to use yarn command in the first step where we build the frontend. And to use Gradle in the second step so the way to do that is using following syntax.<\/p>\n\n\n\n<p>This is called wrapper of those tools that we&#8217;ve configured so the the wrapper is nodejs(&#8216;Node-10.17&#8217;). Here I have to provide the name of that installation. Here so it knows that you are using that installation of node in here.<\/p>\n\n\n\n<p>We create a block and the way you can run these commands is using:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>{\nsh 'yarn install'\n}<\/code><\/pre>\n\n\n\n<p>So I&#8217;m gonna do a yarn I&#8217;m just gonna do yarn install just to demonstrate that the command is there.<\/p>\n\n\n\n<p>In backend section here we&#8217;re gonna use the Gradle command and the wrapper for that is &#8220;withGradle()&#8221; which doesn&#8217;t take anything as a parameter so it&#8217;s just with Gradle and inside of that block we are gonna execute another shell command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>withGradle() {\n      sh '.\/Gradlew -v'\n}<\/code><\/pre>\n\n\n\n<p>It sound like project is set up so I&#8217;m gonna commit that.<\/p>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img decoding=\"async\" src=\"https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_14-7-1024x470.jpg\" alt=\"Building pipeline\" class=\"wp-image-2986\" width=\"768\" height=\"353\" srcset=\"https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_14-7-1024x470.jpg 1024w, https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_14-7-300x138.jpg 300w, https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_14-7-768x353.jpg 768w, https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_14-7.jpg 1365w\" sizes=\"(max-width: 768px) 100vw, 768px\" \/><\/figure>\n<\/div>\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>You see the master branch is scanning jenkinsfile was found and if I go to Master here it&#8217;s building master.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Master Branch Console Output<\/h2>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img decoding=\"async\" src=\"https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_15-5-1024x575.jpg\" alt=\"Console Output\" class=\"wp-image-2987\" width=\"768\" height=\"431\" srcset=\"https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_15-5-1024x575.jpg 1024w, https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_15-5-300x169.jpg 300w, https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_15-5-768x432.jpg 768w, https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_15-5.jpg 1365w\" sizes=\"(max-width: 768px) 100vw, 768px\" \/><\/figure>\n<\/div>\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>If I go inside let&#8217;s actually check the console output and here you see that yarn is executing, yarn installed and this is a version that we provided 1.13.0. Yarn install is running.<\/p>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img decoding=\"async\" src=\"https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_18-8-1024x521.jpg\" alt=\"Jenkinsfile Gradle\" class=\"wp-image-2989\" width=\"768\" height=\"391\" srcset=\"https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_18-8-1024x521.jpg 1024w, https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_18-8-300x153.jpg 300w, https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_18-8-768x391.jpg 768w, https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_18-8.jpg 1365w\" sizes=\"(max-width: 768px) 100vw, 768px\" \/><\/figure>\n<\/div>\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>Now the Gradlew &#8211; v command ran and output the Gradle. Basically this proves that those build tools were installed by Jenkins automatically with the versions that I specified. and the commands run successfully so obviously the same way you can use maven and npm as well.<\/p>\n\n\n\n<p>For example here since we have nodeJS which has NPM already installed instead of yarn you would just use NPM commands. Now there&#8217;s an alternative to using those tools without the wrapper. You may have seen it already in the Jenkinsfile syntax.<\/p>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img decoding=\"async\" src=\"https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_17-7-1024x515.jpg\" alt=\"Tools Syntax\" class=\"wp-image-2988\" width=\"768\" height=\"386\" srcset=\"https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_17-7-1024x515.jpg 1024w, https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_17-7-300x151.jpg 300w, https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_17-7-768x387.jpg 768w, https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/Screenshot_17-7.jpg 1365w\" sizes=\"(max-width: 768px) 100vw, 768px\" \/><\/figure>\n<\/div>\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>There is an attribute called tools and inside that you can configure which tools you are gonna be using in a Jenkinsfile. So it works the same as a wrapper however that tools plugin or the tools attribute supports only three tools by now. And these three tools are maven Gradle and JDK.<\/p>\n\n\n\n<p>To use it i need this command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Tools {\n      gradle 'Gradle-6.2'\n}<\/code><\/pre>\n\n\n\n<p>So basically these indicates to Jenkins that I want to use Gradle in my Jenkinsfile please go and fetch me the Gradle configuration that I&#8217;ve configured in the &#8220;global tool configuration&#8221;.<\/p>\n\n\n\n<p>Update this and scan project go to master and see it&#8217;s built and it ran. I guess my preferred way is to do it like this so all the tools that are supported using this tools attribute. I&#8217;m gonna use them right like this because the steps part will be cleaner without the wrappers.<\/p>\n\n\n\n<p>And for the rest you&#8217;re just gonna have to use the wrapper like this so that&#8217;s how you configure build tools and use them in Jenkins.<\/p>\n\n\n\n<p>For more article please visit our <a href=\"https:\/\/devclouds.io\/blog\/\">blog<\/a> page.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In order to build the application in the package you need some kind of build tools.<\/p>\n","protected":false},"author":5,"featured_media":3188,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[],"class_list":["post-2971","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-devops"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v19.6 (Yoast SEO v19.14) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Configure Build Tools in Jenkins - The Official DevClouds Blogs<\/title>\n<meta name=\"description\" content=\"Configure Build Tools in Jenkins | Install npm and yarn from plugins | Use build tools (gradle and yarn) in Jenkinsfile\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/devclouds.io\/blog\/configure-build-tools-in-jenkins\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Configure Build Tools in Jenkins\" \/>\n<meta property=\"og:description\" content=\"Configure Build Tools in Jenkins | Install npm and yarn from plugins | Use build tools (gradle and yarn) in Jenkinsfile\" \/>\n<meta property=\"og:url\" content=\"https:\/\/devclouds.io\/blog\/configure-build-tools-in-jenkins\/\" \/>\n<meta property=\"og:site_name\" content=\"The Official DevClouds Blogs\" \/>\n<meta property=\"article:published_time\" content=\"2023-01-15T19:27:08+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-01-19T09:01:11+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/demo-y-1.png\" \/>\n\t<meta property=\"og:image:width\" content=\"750\" \/>\n\t<meta property=\"og:image:height\" content=\"400\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"hammad\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"hammad\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"11 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/devclouds.io\/blog\/configure-build-tools-in-jenkins\/\",\"url\":\"https:\/\/devclouds.io\/blog\/configure-build-tools-in-jenkins\/\",\"name\":\"Configure Build Tools in Jenkins - The Official DevClouds Blogs\",\"isPartOf\":{\"@id\":\"https:\/\/devclouds.io\/blog\/#website\"},\"datePublished\":\"2023-01-15T19:27:08+00:00\",\"dateModified\":\"2023-01-19T09:01:11+00:00\",\"author\":{\"@id\":\"https:\/\/devclouds.io\/blog\/#\/schema\/person\/29fe135874604a656a492f57fb43211d\"},\"description\":\"Configure Build Tools in Jenkins | Install npm and yarn from plugins | Use build tools (gradle and yarn) in Jenkinsfile\",\"breadcrumb\":{\"@id\":\"https:\/\/devclouds.io\/blog\/configure-build-tools-in-jenkins\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/devclouds.io\/blog\/configure-build-tools-in-jenkins\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/devclouds.io\/blog\/configure-build-tools-in-jenkins\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/devclouds.io\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Configure Build Tools in Jenkins\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/devclouds.io\/blog\/#website\",\"url\":\"https:\/\/devclouds.io\/blog\/\",\"name\":\"The Official DevClouds Blogs\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/devclouds.io\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/devclouds.io\/blog\/#\/schema\/person\/29fe135874604a656a492f57fb43211d\",\"name\":\"hammad\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/devclouds.io\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/19d1520a5ed46e5c53b8333bc3a9bddb9f28e057d9722fbb8e979edd11e22faf?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/19d1520a5ed46e5c53b8333bc3a9bddb9f28e057d9722fbb8e979edd11e22faf?s=96&d=mm&r=g\",\"caption\":\"hammad\"},\"url\":\"https:\/\/devclouds.io\/blog\/author\/hammad\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Configure Build Tools in Jenkins - The Official DevClouds Blogs","description":"Configure Build Tools in Jenkins | Install npm and yarn from plugins | Use build tools (gradle and yarn) in Jenkinsfile","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/devclouds.io\/blog\/configure-build-tools-in-jenkins\/","og_locale":"en_US","og_type":"article","og_title":"Configure Build Tools in Jenkins","og_description":"Configure Build Tools in Jenkins | Install npm and yarn from plugins | Use build tools (gradle and yarn) in Jenkinsfile","og_url":"https:\/\/devclouds.io\/blog\/configure-build-tools-in-jenkins\/","og_site_name":"The Official DevClouds Blogs","article_published_time":"2023-01-15T19:27:08+00:00","article_modified_time":"2023-01-19T09:01:11+00:00","og_image":[{"width":750,"height":400,"url":"https:\/\/devclouds.io\/blog\/wp-content\/uploads\/2023\/01\/demo-y-1.png","type":"image\/png"}],"author":"hammad","twitter_card":"summary_large_image","twitter_misc":{"Written by":"hammad","Est. reading time":"11 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/devclouds.io\/blog\/configure-build-tools-in-jenkins\/","url":"https:\/\/devclouds.io\/blog\/configure-build-tools-in-jenkins\/","name":"Configure Build Tools in Jenkins - The Official DevClouds Blogs","isPartOf":{"@id":"https:\/\/devclouds.io\/blog\/#website"},"datePublished":"2023-01-15T19:27:08+00:00","dateModified":"2023-01-19T09:01:11+00:00","author":{"@id":"https:\/\/devclouds.io\/blog\/#\/schema\/person\/29fe135874604a656a492f57fb43211d"},"description":"Configure Build Tools in Jenkins | Install npm and yarn from plugins | Use build tools (gradle and yarn) in Jenkinsfile","breadcrumb":{"@id":"https:\/\/devclouds.io\/blog\/configure-build-tools-in-jenkins\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/devclouds.io\/blog\/configure-build-tools-in-jenkins\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/devclouds.io\/blog\/configure-build-tools-in-jenkins\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/devclouds.io\/blog\/"},{"@type":"ListItem","position":2,"name":"Configure Build Tools in Jenkins"}]},{"@type":"WebSite","@id":"https:\/\/devclouds.io\/blog\/#website","url":"https:\/\/devclouds.io\/blog\/","name":"The Official DevClouds Blogs","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/devclouds.io\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/devclouds.io\/blog\/#\/schema\/person\/29fe135874604a656a492f57fb43211d","name":"hammad","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/devclouds.io\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/19d1520a5ed46e5c53b8333bc3a9bddb9f28e057d9722fbb8e979edd11e22faf?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/19d1520a5ed46e5c53b8333bc3a9bddb9f28e057d9722fbb8e979edd11e22faf?s=96&d=mm&r=g","caption":"hammad"},"url":"https:\/\/devclouds.io\/blog\/author\/hammad\/"}]}},"_links":{"self":[{"href":"https:\/\/devclouds.io\/blog\/wp-json\/wp\/v2\/posts\/2971","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devclouds.io\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devclouds.io\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devclouds.io\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/devclouds.io\/blog\/wp-json\/wp\/v2\/comments?post=2971"}],"version-history":[{"count":4,"href":"https:\/\/devclouds.io\/blog\/wp-json\/wp\/v2\/posts\/2971\/revisions"}],"predecessor-version":[{"id":3219,"href":"https:\/\/devclouds.io\/blog\/wp-json\/wp\/v2\/posts\/2971\/revisions\/3219"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devclouds.io\/blog\/wp-json\/wp\/v2\/media\/3188"}],"wp:attachment":[{"href":"https:\/\/devclouds.io\/blog\/wp-json\/wp\/v2\/media?parent=2971"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devclouds.io\/blog\/wp-json\/wp\/v2\/categories?post=2971"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devclouds.io\/blog\/wp-json\/wp\/v2\/tags?post=2971"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}