Jenkins Github Integration Processes

Muhammed Eren Demir
3 min readJun 18, 2021

You will learn more through a developed project.

Greetings, I will not talk about Jenkins at length, if you are in this article, you know more or less.

I have developed a project and when I commit it to GitHub, I want Jenkins to be triggered and the specified actions to be taken. For example, when I commit to Github, I want the code quality of my project to be analyzed with SonarQube. This is where Jenkins comes into play.

In this integration, Github will trigger Jenkins. So Github needs to be able to access Jenkins. First, let’s configure Github and Jenkins integration. Let’s start with the GitHub side!

Configuring Github

Step 1: Go to your GitHub repository and click ‘Settings’.

Step 2: Click on Webhooks and then click on ‘Add webhook’.

Step 3: Paste your Jenkins environment URL in the ‘Payload URL’ field. Add /GitHub-webhook/ to the end of this URL. Select application/json in the ‘Content type’ field and leave the ‘Secret’ field blank.

Step 4: ‘ Which events would you like to trigger this webhook?’ ‘ Let me select individual events.’ Then check the ‘Pull requests’ and ‘Pushes’ options. At the end of this option, make sure ‘Active’ is checked and click ‘Add webhook’.

We’re done with the configuration on GitHub! Now let’s move on to Jenkins.

Configuring Jenkins

Step 5: Click ‘New Item’ to create a new project in Jenkins.

Step 6: Give your project a name, choose ‘Free Project’ or ‘Pipeline’ and finally click ‘OK.

Step 7: Click on the ‘Advanced Project Options’ tab and select ‘Pipeline script from SCM’ in the ‘Definition’ and then select the ‘SCM’ field as ‘Go’.

Step 8: Click on Git and paste your GitHub repository URL into the ‘Repository URL’ field, note that the URL should have .git at the end. In the ‘Script Path’ field, we must give the name of the file in the root part of my codes where the work that Jenkins will do.

Step 9: After selecting ‘General’, the URL of our Github repo will be entered in the ‘Github project’ field and the point to be noted is that .git should not be at the end of our URL.

Step 10: After selecting ‘Build Triggers’, ‘GitHub hook trigger for GITScm polling’ will be selected

the integration is complete, now Jenkins will access our code on Github and execute the commands we want it to do on every push.

Thank you for reading!

--

--

Muhammed Eren Demir

I am software developer. I'm improving myself on Java and devops. I'm working java and devops software in DetaySoft.