Maven (Contd..)
Maven Plugins
- In maven what we give is a goal (mvn package)
- Maven works with plugins to acheive goals. General plugins
- Create jar/war file
- Compile code
- unit testing code
- Creating docs
- Creating Reports
- If your org uses third party plugins for build activities add the following section to the pom.xml
<build>
<plugins>
<plugin>
</plugin>
</plugins>
</build>
Snapshots VS Releases
- If your build is not a release, then it is called as SNAPSHOT. See the version
<version>1.0-SNAPSHOT</version>
in pom below
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.qualitythought.devops</groupId>
<artifactId>hello-maven</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>29.0-jre</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
- If your version doesn’t have SNAPSHOT Term or if it has RELEASE TERM, It is considered to be release version, For the Release Version would be
<version>1.1</version>
or<version>1.1.RELEASE</version>
Test Results and Package Locations
- Generally Test results will be in target/surefire-reports/*.xml
- Package will be in target folder
Lets Try to Build Java Project in Jenkins and show test results
- Create a freestyle project with Build using Invoke top level maven targets
- After Build Navigate to workspace folder
- Lets archive the Package for every build
- Lets also show the test results to the user
- Jenkins understands test results which are generated in Junit xml format or some users show html file
- Jenkins understands test results which are generated in Junit xml format or some users show html file
Jenkins Adminstration
Restart/Shutdown Jenkins
User Management in Jenkins: