Day 24 of #90DaysOfDevOps

Day 24 of #90DaysOfDevOps

In today's blog we will see how to pull code from GitHub and configure the jobs to run code pulled from GitHub.

First, we need to install Git and GitHub plugins. Jenkins will install these if you choose to install suggested plugins while Launching Jenkins for the first time.

Let's, configure a job to clone a repo.

  1. Click on New Item.

  2. Enter an Item name and choose freestyle project

  1. Go to Source Code Management

  2. Add your GitHub repo URL

  3. Choose branch "Branches to Build"

  4. Now click on Apply and Save

  1. Build the Job

  1. Check the console output. You can see that the GitHub repo is being cloned to the Jenkins workspace - /var/lib/jenkins/workspace/DemoGitPull.

  1. Also, you can check that the code/files from GitHub are present in the Jenkins workspace folder.

Executing a shell script which we cloned from GitHub repo earlier.

  1. Go to configure section

  2. Go to Build steps

  3. Choose "Execute shell"

  4. Add a shell command to be executed.

  1. You can see shell script output in the console output.