DevOps for Salesforce
上QQ阅读APP看书,第一时间看更新

Configuring Maven in the Jenkins server

Go to Manage Jenkins | Global Tool Configuration.

We have already installed Maven on our machine. So enter a name for the Maven installation and the M2_HOME path as follows:

Let's configure our Jenkins job to build our sample project:

  1. Click on create new jobs:
  1. Create a Jenkins job with the Maven plugin. Provide the job name devops-ci-cd (you can choose another project name, if you want):
  1. In the Source Code Management section, provide the Git URL of your project. Provide credentials to clone the repository in Jenkins:
  1. Choose GitHub hook trigger for GitScm polling in Build Triggers. If Jenkins receives a PUSH GitHub webhook from the preceding repository, it will trigger this job:
  1. Provide a path to root pom.xml. It will be a relative path to the module root. In Build, add Root POM as pom.xml and Goals and options as package:
  1. Save your work and click on Build now.

This will create my-app-1.0-SNAPSHOT.jar in the /var/lib/Jenkins/workspace/target folder. You can check the console logs while the project build is in progress.

Once the JAR is successfully built, you can see the console logs as shown in the following screenshot:

We have completed a continuous integration job successfully. Now, we need to add the Jenkins webhook URL in the GitHub settings to trigger a Jenkins build whenever someone pushes code to our GitHub project.