Skip to content

Practice Exercise 2: Working with Different Projects

Objectives

  • Familiarize with the different types of Jenkins projects

  • Demonstrate how to integrate Jenkins with GitHub as a version control system.

  • By the end of this exercise, you should be able to create and configure Jenkins projects for different purposes and integrate them with a GitHub repository.

Prerequisites

  • Jenkins installed and running.

  • A GitHub account.

  • Access your lab instance by following the instructions in accessing your Lab Environment.

Access Jenkins

  1. Get the ip address of your lab instance.

  2. Open your web browser and navigate to http://your_lab_ip:8080.

  3. Your login name is the letter of your first name (second name not included) and your lastname (i.e. Mark Jimmy Santos = msantos). Password is the same as the password provided by your instructor.

Duration: 60 minutes

Tasks

Important Notes:

  1. Always take note of the build/project url.

  2. Use this form to input the build/project on each task.

Part 1: Jenkins Project Types

In this part of the exercise, you will explore different types of Jenkins projects.

Freestyle Project:

  1. Create a new Freestyle Project in Jenkins.

  2. Configure it to build a simple "Hello World" application. Use a shell script or batch command to echo "Hello, World!".

  3. Provide the url of the freestyle job.

Multi-Project Job:

  1. Create a new Multi-Project in Jenkins.

  2. Configure it to build a simple "Hello World" application. Use a shell script or batch command to echo "Hello, World!".

  3. Provide the url of the Multi-Project job.

Part 2: GitHub Integration

In this part of the exercise, you will integrate Jenkins with GitHub as a version control system.

GitHub Setup:

  1. Create a new public GitHub repository (or use an existing one) to host your code.

  2. Push the "Hello World" application code to the GitHub repository.

Jenkins-GitHub Integration:

  1. Install and configure the GitHub plugin in Jenkins.

  2. Create a new Jenkins job (Freestyle or Pipeline) and set up the integration with your GitHub repository. Use "GitHub project" to specify the GitHub repository URL.

  3. Configure a webhook in the GitHub repository settings to trigger the Jenkins build on code changes.

Testing the Integration:

  1. Make a change to the code in your GitHub repository and commit the changes.
  2. Observe how Jenkins automatically triggers a build when changes are pushed to the repository.
  3. Verify that the "Hello, World!" application is built successfully.

    Note: Provide the project url in form provided.

Conclusion

In this lab exercise, you learned how deal with different Jenkins project types. You are able to explore the freestyle and multi-project job. In addition, you are able to experience configuring your github integrated with Jenkins.