LightBlog

Jenkins - Configuring Build job for Java Application with Maven


1.Go to Jenkins Dashboard and click on New Item.
·         Enter an item name such as PetClinic.
·         Select Freestyle project.
·         Click on OK.
Job is created in this location: C:\Users\satya\.jenkins\jobs\PetClinic


2.Github SSH connection
1.Execute ssh-keygen -t rsa -b 4096 -C "smlcodes@gmail.com" command by substituting in GitHub email address.key generated in C:\Users\satya/.ssh/id_rsa

2. To configure GitHub account to use new SSH key, add it to your GitHub account. Go to https://github.com/smlcodes and click on Settings > SSH and GPG keys > Add SSH : copy id_rsa.pub & paste it here.

3.After that verify the Connection.
satya@DESKTOP-I4LP77B MINGW64 ~
$ ssh -T git@github.com
Are you sure you want to continue connecting (yes/no)? yes
Hi smlcodes! You've successfully authenticated.


3. Configure PetClinic build job.
1. Go to dashboard > Petclinic Project > Configure > Source Code Management : provide github project clone url & Save


2.Build Triggers, Select : GitHub hook trigger for GITScm polling


3.Build: Add build step > Invoke top-level maven Targets.


4. Build Now : Save & Trigger the job manually.

5. Once source code is available in the build job's workspace, Maven target will be executed and war file will be created. Verify the build status.
[INFO] Building jar: C:\Users\satya\.jenkins\workspace\PetClinic\target\spring-petclinic-2.1.0.BUILD-SNAPSHOT.jar
[INFO]
[INFO] --- spring-boot-maven-plugin:2.1.0.BUILD-SNAPSHOT:repackage (repackage) @ spring-petclinic ---
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
[INFO] Replacing main artifact C:\Users\satya\.jenkins\workspace\PetClinic\target\spring-petclinic-2.1.0.BUILD-SNAPSHOT.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 19:28.000s
[INFO] Finished at: Sun Oct 14 12:09:45 IST 2018
[INFO] Final Memory: 90M/214M
[INFO] ------------------------------------------------------------------------
Finished: SUCCESS

6. To verify the workspace of a build Job, click on the Workspace link. Verify all the files available in the workspace. We can find these files in .jenkins folder under specific build job (C:\Users\satya\.jenkins\workspace\PetClinic).



Integrating JUnit
Our sample application has JUnit test cases and to execute them, we need to configure JUnit related settings in build job configuration.

1.In Post-Build Actions, select Publish JUnit test result report.

2.Provide path for Test Report XMLs based on the workspace.

Click on Apply and then click on Save.

3.Once we configure JUnit settings in a build, wait for the build execution based on scheduling or click on the Build Now link.

4.Verify the build status on Jenkins dashboard and you will see Test Result link with small summary. Click on the Test Result link.

Dashboard view plugin
Dashboard View plugin provides different view implementation considering portal kind of layout. We can select different build jobs to be included in new view and configure different portlets for view.

1.Go to Plugin Manager from Manage Jenkins, and click on the Available Tab. Search for Dashboard View plugin and click Install without restart.

2.Once installation of Dashboard View plugin is completed successfully, we can create a new view by clicking on the + sign on Jenkins dashboard.

3.Enter View name, select view type and click on OK.

Share on Google Plus

About Unknown

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.

0 comments:

Post a Comment