Skip to main content

Building from SCM

Hands-On Lab

 

Photo of Michael McClaren

Michael McClaren

Linux Training Architect I in Content

Length

01:00:00

Difficulty

Intermediate

In this lab we configure Maven to perform a build. This includes pulling the source code for the build from SCM. At the end of the build process, we also create an artifact for the build.

What are Hands-On Labs?

Hands-On Labs are scenario-based learning environments where learners can practice without consequences. Don't compromise a system or waste money on expensive downloads. Practice real-world skills without the real-world risk, no assembly required.

Building from SCM

Introduction

In this lab we configure Maven to perform a build. This includes pulling the source code for the build from SCM. At the end of the build process, we also create an artifact for the build.

Solution

Configure Maven Installer

  1. Use a browser to navigate to the provided public IP address for the server. Remember to add ":8080" to the end of the IP address to specify the default Jenkins port.

  2. Log in with the credentials provided in the lab guide instructions.

  3. Click Manage Jenkins.

  4. Click Global Tool Configuration.

  5. Under Maven installations, click Add Maven.

  6. In the Name box, enter "M3".

  7. Make sure Install automatically is checked.

  8. Click Save.

Configure the Build to Use Maven and Make the Index File

  1. Click New Item.

  2. Enter an item name of "mavenproject" in the box provided.

  3. Select Freestyle project.

  4. Click OK.

  5. Click the Source Code Management tab at the top of the screen.

  6. Select the option for a Git repository.

  7. Copy the git repository link from the lab instructions and enter it into the Repository URL box.

  8. Click the Build tab at the top of the screen.

  9. Click Add build step and select the Invoke top-level Maven targets option.

  1. Under Maven Version, select M3.

  2. In the Goals box, enter "clean package".

  3. Click Add build step and select the Execute shell option.

  4. In the Command window, enter "bin/makeindex".

  5. Click Add post-build action and select the Archive the artifacts option.

  6. Inside the Archive the artifacts box, click Advanced...

  7. Check the option for Fingerprint all archived artifacts.

  8. In the Files to archive box, enter "index.jsp".

  9. Click Save.

  10. Click Build Now.

  11. Refresh the window and click the View link next to index.jsp. Verify the contents of the index.jsp file.

Conclusion

Congratulations — you've completed this hands-on lab!