What is Apache Maven? Apache Maven is a widely-used build automation and project management tool. It is part o...
What is Apache Maven?
Apache Maven is a widely-used build automation and project management tool.
It is part of the Apache Software Foundation and is designed to simplify the build process for Java-based projects. Maven uses a declarative approach, allowing developers to define project structures, and dependencies, and build configurations in a concise and standardized way.
Key features of Apache Maven
- Project Object Model (POM):
- Dependency Management
- Build Lifecycle
- Plugins
- Convention over Configuration
- Central Repository
Using Maven can help standardize the build process across different projects, improve collaboration, and enhance project maintainability. Many Java-based projects, especially those developed within the Apache Software Foundation, use Maven as their build tool.
How to configure Maven inside the Jenkins server?
How to configure Maven inside the Jenkins server?
To install the maven locally we need to download the source code package from the Apache official website
Download the Package from the Maven Repo using the below command, before downloading the source code switch the /opt directory
note: The Maven version might be changed, please check and download the latest version from the apache maven website.
commands cd /opt wget https://dlcdn.apache.org/maven/maven-3/3.8.6/binaries/apache-maven-3.8.6-bin.tar.gz
tar -xvf apache-maven-3.8.6-bin.tar.gz
Download the Package from the Maven Repo using the below command, before downloading the source code switch the /opt directory
note: The Maven version might be changed, please check and download the latest version from the apache maven website.
commands cd /opt wget https://dlcdn.apache.org/maven/maven-3/3.8.6/binaries/apache-maven-3.8.6-bin.tar.gz
tar -xvf apache-maven-3.8.6-bin.tar.gz
mv apache-maven-3.8.6 maven
After downloading the File we need to the maven running path by setting it as an env variable in the linux. for that, we need to open the file .bash_profile using Vi editor. declare the maven path and maven's execution path as M2_HOME and M2 and set those values as env variables.
M2_HOME=/opt/maven
M2=/opt/maven/bin
Path add the $M2_HOME:$M2
Once the env variables are set run the below command to update and verify the Maven's path and verify the version of the Maven
command:
Once the env variables are set run the below command to update and verify the Maven's path and verify the version of the Maven
command:
source ~/.bash_profile
echo $PATH
mvn --version
Now successfully maven installed, we need to set the maven path in jenkins
before setting up the maven Path inside jenkins we need to enable the maven integration plugins inside jenkins.
Once the plugins are installed click manage jenkins --> Tools and scroll down until the maven installations step.
Click add Maven → for the name need to give the as maven and maven_home path also need to give the home path /opt/maven → click apply and save.
mvn --version
Now successfully maven installed, we need to set the maven path in jenkins
before setting up the maven Path inside jenkins we need to enable the maven integration plugins inside jenkins.
Once the plugins are installed click manage jenkins --> Tools and scroll down until the maven installations step.
Click add Maven → for the name need to give the as maven and maven_home path also need to give the home path /opt/maven → click apply and save.
Optionally we can use install automatically to install maven. Now, we can create the new Maven project with SCM and build the package using Maven.
Log in to Jenkins and create a new job by clicking the option new item and create the maven build job
Inside the maven configuration, we need to add a github repo by clicking Git and adding the github repo. the repo you can able to find inside my github repos.
Inside the Build configuration goals need to be given as clean install click save and build the job.
Now, we need to check the logs for success and error logs, If the job is successful we can find the build package path inside the server.
----------------------------------------!!!! Happy Learning with Techiev !!!!!!!!----------------------------------
-------------------------Subscribe our Youtube Channel by clicking the below link----------------------
----------------------------!!https://www.youtube.com/@techieview729!!---------------------