“DevOps: Jenkins & AWS Series, Part 5: Gradle Installation on Ubuntu 22.04 with java 11 & Jenkins Integration — A Step-by-Step Guide”
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:
- Ubuntu 22.04: Ensure that you have a system running Ubuntu 22.04. This tutorial is specifically tailored for this version of Ubuntu.
- 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.
- 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
- Log in to your Jenkins dashboard.
- Navigate to “Manage Jenkins” > “Global Tool Configuration.”
- Scroll down to the “Gradle” section and click “Add Gradle.”
- Provide a name for the Gradle installation (e.g., “Gradle-7.4.4”).
- Select “Install automatically.”
- Choose the desired Gradle version from the “Version” dropdown list, or select “Specify Version” and enter “7.4.4” manually.
- Save the configuration.
Step 4: Create a Gradle Job in Jenkins
- Go back to the Jenkins dashboard.
- Click on “New Item” to create a new job.
- Enter a name for the job (e.g., “GradleJob”) and select “Freestyle project.”
- Click “OK” to create the job.
- In the “Source Code Management” section, select “Git” and provide the repository URL containing your Gradle project.
- In the “Build Triggers” section, choose the desired build trigger option (e.g., “Poll SCM” or “GitHub hook trigger for GITScm polling”).
- In the “Build” section, click on “Add build step” and select “Invoke Gradle script.”
- Choose the Gradle installation configured in Step 3 from the “Gradle Version” dropdown list.
- Enter the desired Gradle tasks (e.g., “clean build”) in the “Tasks” field.
- Save the job configuration.
Step 5: Build the Gradle Job
- Go to the job’s main page in Jenkins.
- 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.
For more info please connect & Follow me:
Github: https://github.com/manikcloud
LinkedIn: https://www.linkedin.com/in/vkmanik/
Email: varunmanik1@gmail.com
Facebook: https://www.facebook.com/cloudvirtualization/
YouTube: https://bit.ly/32fknRN
Twitter: https://twitter.com/varunkmanik