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.
Click on New Item.
Enter an Item name and choose freestyle project
Go to Source Code Management
Add your GitHub repo URL
Choose branch "Branches to Build"
Now click on Apply and Save
- Build the Job
- Check the console output. You can see that the GitHub repo is being cloned to the Jenkins workspace - /var/lib/jenkins/workspace/DemoGitPull.
- 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.
Go to configure section
Go to Build steps
Choose "Execute shell"
Add a shell command to be executed.
- You can see shell script output in the console output.