Operations 6 min read

Integrating Maven, Ant, Gradle, and NPM with Jenkins: Prerequisites, Installation, Configuration, and Common Commands

This guide explains how to integrate Maven, Ant, Gradle, and NPM with Jenkins, covering prerequisites, installation steps, Jenkins configuration, and common build commands for each tool, including setting environment variables, creating Jenkinsfiles, and verifying the setup with test builds.

DevOps Cloud Academy
DevOps Cloud Academy
DevOps Cloud Academy
Integrating Maven, Ant, Gradle, and NPM with Jenkins: Prerequisites, Installation, Configuration, and Common Commands

1. Integrate Maven

1.1 Prerequisites

JDK: Maven 3.3+ requires JDK 1.7+. Memory: no minimum.

Disk: 1G+ free space. OS: no restriction.

Download Maven Download

1.2 Install Maven

tar zxf apache-maven-3.6.0-bin.tar.gz -C /usr/local/
# set global variables (/etc/profile)
export MAVEN_HOME=/usr/local/apache-maven-3.6.0
export PATH=$PATH:$MAVEN_HOME/bin
source /etc/profile

1.3 Jenkins configure Maven

System Settings → Global Tool Configuration

Write Jenkinsfile

node {
    stage ("build"){
        mavenHome = tool 'M3'
        sh "${mavenHome}/bin/mvn -v"
    }
}

Build test – Maven integration completed.

1.4 Common Maven Commands

clean install -DskipTests
clean package

2. Integrate Ant

2.1 Prerequisites

Download Download

2.2 Install Ant

tar zxf apache-ant-1.10.5-bin.tar.gz -C /usr/local/
# add global variables (/etc/profile)
export ANT_HOME=/usr/local/apache-ant-1.10.5
export PATH=$PATH:$MAVEN_HOME/bin:$ANT_HOME/bin
source /etc/profile

Test

2.3 Jenkins configure Ant

System Settings → Global Tool Configuration

Write Jenkinsfile

node {
    stage ("build"){
        antHome = tool 'ANT'
        sh "${antHome}/bin/ant -version"
    }
}

Build test – Ant integration completed.

2.4 Common Ant Command

ant -buildfile -f build.xml

3. Integrate Gradle

3.1 Prerequisites

Download Download

3.2 Install Gradle

unzip gradle-5.3-bin.zip -d /usr/local/
# add global variables (/etc/profile)
export GRADLE_HOME=/usr/local/gradle-5.3
export PATH=$PATH: $GRADLE_HOME/bin
source /etc/profile

3.3 Jenkins configure Gradle

System Settings → Global Tool Configuration

Write Jenkinsfile

node {
    stage ("gradlebuild"){
        gradleHome = tool 'GRADLE'
        sh "${gradleHome}/bin/gradle -v"
    }
}

Build test – Gradle configuration completed.

3.4 Common Gradle Commands

./gradlew -v (shows version, first run downloads Gradle if missing)

./gradlew clean (deletes build folder under HelloWorld/app)

./gradlew build (checks dependencies and compiles package)

./gradlew assembleDebug (builds and packages Debug version)

./gradlew assembleRelease (builds and packages Release version)

./gradlew installRelease (packages and installs Release mode)

./gradlew uninstallRelease (uninstalls Release mode package)

4. Integrate NPM

4.1 Prerequisites

Download Download

4.2 Install Node

tar xf node-v10.15.3-linux-x64.tar.xz -C /usr/local/
# add global variables (/etc/profile)
export NODE_HOME=/usr/local/node-v10.15.3-linux-x64
export PATH=$PATH: $NODE_HOME/bin
source /etc/profile

Test

4.3 Jenkins configure NPM

Node is not listed in Jenkins global tools; define it directly in Jenkinsfile.

Jenkinsfile

node {
    stage ("npmbuild"){
        sh """
           export npmHome=/usr/local/node-v10.15.3-linux-x64
           export PATH=$PATH:$npmHome/bin
           npm -v
           """
    }
}

Build test

4.4 Common NPM Build Command

npm install && npm run build

Read the original article!!

CI/CDGradleMavenbuild-toolsnpmJenkinsAnt
DevOps Cloud Academy
Written by

DevOps Cloud Academy

Exploring industry DevOps practices and technical expertise.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.