As an automation tester, I want to use Jenkins tools to setup my CICD job for my Maven Project. But the Jenkins is not support Maven project indefault. Therefore, I need to setup Jenkins to able to work with me Jenkins project
Jenkins - Setup Maven
To setup Maven:
- Access
Dashboard > Manage Jenkins > Plugin > Available Pluginand installMaven Integrationplugin - Access
Dashboard > Manage Jenkins > Toolsand move toMavensection- Click on
Add maven - Input maven name (any name) that will be use in the Jenkinsfile (Example
maven 'maven'for the name ismaven) - Select the maven version (any version that adapt with our project)
- Click
Save
- Click on
Jenkins - Use Maven on Jenkins Pipeline Project
In Jenkinsfile, if the maven name is maven, we will use the tool is maven 'maven' to use the Maven on our project. Then, in the stage, we can run the project with the command mvn clean install as in the example.
Jenkinsfile sample:
pipeline {
agent any
tools{
maven 'maven'
}
stages {
stage('Tests') {
steps {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE'){
sh 'mvn clean install'
}
}
}
//....
}
}