Build
In this section, We will setting to build java web app with maven.
Maven installation
First step, maven should be installed in machine witch running Jenkins job. To check this, just open command prompt and typing in mvn --help , you will some all available maven command.
In case maven not yet install follow these steps to do maven installation (for Window)
- Download maven from link http://maven.apache.org/download.cgi
- Unzip zip file to one folder (for example I unzip to C:\apache-maven-3.3.9)
- Add M2_HOME and MAVEN_HOME variable point to above foder
- Add mavin bin to Path variable so you can call maven from any place
That it, to check maven installed successfully, open cmd and typing in mvn --help
Help content for mvn should show up correctly
Try to run maven build manually
Now maven is ready, we can try to run the build for source code which we just clone from Github repository at source code management step.
Open cmd and change directory to repository GOL folder. And then typing in mvn install
This command will run java source unit test and then build this web application to a .war file
You will build result from command prompt
And can see actual .war file inside target folder of gameoflife-web. This folder could be use to deploy with web application server.
Configure Build Step
From GOL job dashboard, click to Configure link, the configure page will show up
From configure page, select Build tab, page will scroll down to Add build step
Click to Add build step and select Invoke top-level Maven targets
Section to adding maven command will show up as below
Put Goals maven command clean install
Then finally click in to Save button. That it we already complete configure for build maven step.
Check Log and Workspace
Now from dashboard of GOL, just click to Build Now to see how Jenkins job work by open console log
Scroll this log to bottom you will see build job run successfully
From GOL home page, click to Workspace
You will access directory where build happen and actually could see the war file inside Gameoflife-web/target/. You could actually download war file from here.
That it, We already finish setting up build step.