For this tutorial, I assume that you already have a Jenkins server, Git and GitHub plugin installed on Jenkins and has admin access on your project on GitHub.
Step 1:
- Go to your Jenkins server then click on the new item.
Step 2:
- Enter your project name
- Select on freestyle project
- Click OK
Step 3:
- After creating a new project navigate to the Source Code Management section
- Click on Git
- Enter GitHub repository URL
- Enter Branch
Note: In order for this to work you must need to generate a personal access token in order for Jenkins to communicate with your repo.
3.1
- Navigate to https://github.com (assumed that you already logged in)
- Click on settings
- Click on Personal access token
- Then click on Generate access token
- Enter token description
- Check on the repo, this will grant repo access on this token e.g. push/pull
- Click Generate Token
- After generating the token, get the generated token and append it to your repo web URL
e.g. https://{generated-token}@github.com/reponame/test.git
- Then paste it on Jenkins repository URL
Step 4:
- Navigate to Build Triggers section
- Check GITScm polling
- Then save
Step 5:
- Go to your project GitHub repository
- Click on settings
- Integration & services
- Add Service
- Select on GitHub plugin
Step 6:
- Enter Jenkins URL
- Save service