“DevOps: Jenkins & AWS Series, Part 5: Gradle Installation on Ubuntu 22.04 with java 11 & Jenkins Integration — A Step-by-Step Guide”

Varun Kumar Manik
3 min readApr 15, 2023

--

Introduction:

In this blog post, we will guide you through the process of installing Gradle on Ubuntu 22.04, integrating it with Jenkins, and creating a Gradle job. We assume that you have already installed Jenkins, as covered in Part 1 of this series. Let’s get started with Gradle installation and configuration.

Prerequisites:

Before proceeding with this tutorial, make sure you have the following prerequisites met:

  1. Ubuntu 22.04: Ensure that you have a system running Ubuntu 22.04. This tutorial is specifically tailored for this version of Ubuntu.
  2. Jenkins: You should have Jenkins installed and running on your Ubuntu 22.04 system. If you haven’t installed it yet, please follow the instructions provided in Part 1 of this series. Ensure that you have administrative access to your Jenkins instance.
  3. Java 11: Gradle requires Java to function. Make sure you have Java 11 installed on your Ubuntu 22.04 system. You can check your Java version by running the following command:
java -version

4. Git: Ensure that Git is installed on your system, as you’ll need it to clone and manage repositories. You can check if Git is installed by running the following command:

git --version

A Gradle project: You should have a Gradle project that you want to build using Jenkins. This project can be stored in a local or remote Git repository.

Once you have met all the prerequisites, you can proceed with the tutorial to install Gradle, configure Jenkins, and create a Gradle job.

Step 1: Install Gradle on Ubuntu 22.04 To install Gradle 7.4.4,

Follow these commands:

sudo apt update
sudo apt install -y software-properties-common
sudo add-apt-repository -y ppa:cwchien/gradle
sudo apt update
sudo apt install -y gradle=7.4.4-0ppa1

Step 2: Verify Gradle Installation Check the installed Gradle version by running:

gradle -v

You should see Gradle 7.4.4 in the output.

Step 3: Configure Jenkins for Gradle

  1. Log in to your Jenkins dashboard.
  2. Navigate to “Manage Jenkins” > “Global Tool Configuration.”
  3. Scroll down to the “Gradle” section and click “Add Gradle.”
  4. Provide a name for the Gradle installation (e.g., “Gradle-7.4.4”).
  5. Select “Install automatically.”
  6. Choose the desired Gradle version from the “Version” dropdown list, or select “Specify Version” and enter “7.4.4” manually.
  7. Save the configuration.

Step 4: Create a Gradle Job in Jenkins

  1. Go back to the Jenkins dashboard.
  2. Click on “New Item” to create a new job.
  3. Enter a name for the job (e.g., “GradleJob”) and select “Freestyle project.”
  4. Click “OK” to create the job.
  5. In the “Source Code Management” section, select “Git” and provide the repository URL containing your Gradle project.
  6. In the “Build Triggers” section, choose the desired build trigger option (e.g., “Poll SCM” or “GitHub hook trigger for GITScm polling”).
  7. In the “Build” section, click on “Add build step” and select “Invoke Gradle script.”
  8. Choose the Gradle installation configured in Step 3 from the “Gradle Version” dropdown list.
  9. Enter the desired Gradle tasks (e.g., “clean build”) in the “Tasks” field.
  10. Save the job configuration.

Step 5: Build the Gradle Job

  1. Go to the job’s main page in Jenkins.
  2. Click “Build Now” to trigger the Gradle job.

Conclusion:

In this blog post, we have successfully installed Gradle on Ubuntu 22.04, integrated it with Jenkins, and created a Gradle job. Now you can use Jenkins to automate and manage your Gradle projects efficiently. Explore more features and plugins available in Jenkins and Gradle to enhance your CI/CD pipeline and optimize your project’s build process.

--

--

Varun Kumar Manik

AWS APN Ambassador | SME of DevOps DevSecOps | Cloud Architect & Trainer | Blogger | Youtuber |Chef