{"id":16112986,"url":"https://github.com/guilospanck/jenkins-github-polling","last_synced_at":"2026-05-05T07:31:16.744Z","repository":{"id":103567048,"uuid":"431572094","full_name":"Guilospanck/jenkins-github-polling","owner":"Guilospanck","description":"Tutorial on how to use Jenkins with GitHub and take advantage of the polling system.","archived":false,"fork":false,"pushed_at":"2021-11-24T18:57:29.000Z","size":22,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-06T07:28:02.395Z","etag":null,"topics":["github","jenkins","polling"],"latest_commit_sha":null,"homepage":"https://medium.com/@guilospanck/how-to-use-jenkins-to-deploy-apps-directly-from-github-to-aws-ec2-78d607442325","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Guilospanck.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-11-24T17:25:29.000Z","updated_at":"2022-12-14T14:47:42.000Z","dependencies_parsed_at":null,"dependency_job_id":"d2cdf825-bf8c-4782-83f7-17fa08f92d3d","html_url":"https://github.com/Guilospanck/jenkins-github-polling","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Guilospanck/jenkins-github-polling","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Guilospanck%2Fjenkins-github-polling","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Guilospanck%2Fjenkins-github-polling/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Guilospanck%2Fjenkins-github-polling/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Guilospanck%2Fjenkins-github-polling/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Guilospanck","download_url":"https://codeload.github.com/Guilospanck/jenkins-github-polling/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Guilospanck%2Fjenkins-github-polling/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32640533,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-04T10:08:07.713Z","status":"online","status_checked_at":"2026-05-05T02:00:06.033Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["github","jenkins","polling"],"created_at":"2024-10-09T20:09:54.963Z","updated_at":"2026-05-05T07:31:16.728Z","avatar_url":"https://github.com/Guilospanck.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Jenkins GitHub Polling\nTutorial on how to use Jenkins with GitHub and take advantage of the polling system.\n\n# Table Of Contents\n- [Installation](#installation)\n  - [Java](#java)\n  - [Jenkins](#jenkins)\n- [Configuration](#configuration)\n  - [Jenkins](#jenkins-1)\n  - [Adding GitHub Credentials](#adding-github-credentials)\n  - [Adding repository polling on GitHub](#adding-repository-polling-on-github)\n  - [Jenkins configuration with GitHub Polling on Push](#jenkins-configuration-with-github-polling-on-push)\n- [Example of Jenkinsfile](#example-of-jenkinsfile)\n- [Jenkins Workspace Directory](#jenkins-workspace-directory)\n- [Common errors in Jenkinsfile](#common-errors-in-jenkinsfile)\n  - [Authentication error in Jenkins on using sudo](#authentication-error-in-jenkins-on-using-sudo)\n\n## Installation\n\n### Java\nFirstly you'll have to install Java JDK, JRE (credits to [DigitalOcean - How To Install Java with Apt on Ubuntu 20.04](https://www.digitalocean.com/community/tutorials/how-to-install-java-with-apt-on-ubuntu-20-04#installing-specific-versions-of-openjdk)).\n\n```bash\nsudo apt update\n```\nNext, check if Java is already installed:\n```bash\njava -version\n```\nIf Java is not currently installed, you’ll see the following output:\n```bash\nCommand 'java' not found, but can be installed with:\n\nsudo apt install openjdk-11-jre-headless  # version 11.0.11+9-0ubuntu2~20.04, or\nsudo apt install default-jre              # version 2:1.11-72\nsudo apt install openjdk-13-jre-headless  # version 13.0.7+5-0ubuntu1~20.04\nsudo apt install openjdk-16-jre-headless  # version 16.0.1+9-1~20.04\nsudo apt install openjdk-8-jre-headless   # version 8u292-b10-0ubuntu1~20.04\n```\nExecute the following command to install the default Java Runtime Environment (JRE), which will install the JRE from OpenJDK 11:\n```bash\nsudo apt install default-jre\n```\nNext, check if Java is already installed:\n```bash\njava -version\n```\nYou’ll see output similar to the following:\n```bash\nopenjdk version \"11.0.11\" 2021-04-20\nOpenJDK Runtime Environment (build 11.0.11+9-Ubuntu-0ubuntu2.20.04)\nOpenJDK 64-Bit Server VM (build 11.0.11+9-Ubuntu-0ubuntu2.20.04, mixed mode, sharing))\n```\nYou may need the Java Development Kit (JDK) in addition to the JRE in order to compile and run some specific Java-based software. To install the JDK, execute the following command, which will also install the JRE:\n```bash\nsudo apt install default-jdk\n```\nVerify that the JDK is installed by checking the version of javac, the Java compiler:\n```bash\njavac -version\n```\n\n### Jenkins\nFirst, add the repository key to the system (credits to [DigitalOcean - How To Install Jenkins on Ubuntu 20.04](https://www.digitalocean.com/community/tutorials/how-to-install-jenkins-on-ubuntu-20-04)):\n\n```bash\nwget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add -\n```\nAfter the key is added the system will return with OK.\nNext, let’s append the Debian package repository address to the server’s sources.list:\n```bash\nsudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ \u003e /etc/apt/sources.list.d/jenkins.list'\n```\n```bash\nsudo apt update\n```\nFinally, we’ll install Jenkins and its dependencies.\n```bash\nsudo apt install jenkins\n```\nStart and verify if Jenkins is running:\n```bash\nsudo systemctl start jenkins\nsudo systemctl status jenkins\n```\n\n## Configuration\n\n### Jenkins\nGo to ```http://your_server_ip_or_domain:8080``` to configure Jenkins. You'll see this image:\n![image](https://user-images.githubusercontent.com/22435398/143280579-41217dbf-38d6-495a-8f3c-9af0baa96bfb.png)\nGet the password from:\n```bash\nsudo cat /var/lib/jenkins/secrets/initialAdminPassword\n```\nInstall suggested plugins:\n![image](https://user-images.githubusercontent.com/22435398/143280671-b45f5887-3c55-4615-b50d-b5ba346a4449.png)\nCreate your new user and password for the Jenkins server.\n\n### Adding Github credentials\nGo to Manage Jenkins\n![image](https://user-images.githubusercontent.com/22435398/143283266-9fbb21bb-9c1c-4612-bfc4-d1a4db87ef53.png)\n\nThen hit Manage Credentials\n![image](https://user-images.githubusercontent.com/22435398/143283364-6484554a-7c3a-42ce-8e17-e28fdd9b8f3a.png)\n\nThen go to Global\n![image](https://user-images.githubusercontent.com/22435398/143283461-3a84c346-4f3c-43b6-b78d-407e9bed3a44.png)\n\nAdd Credential\n![image](https://user-images.githubusercontent.com/22435398/143283553-b8ca550b-a222-43d9-8e8a-d327cb461a02.png)\n\nIf you're using a PAT (Personal Access Token):\n- Kind: select ```Username with Password```\n- Scope: Global (Jenkins, nodes...)\n- Username: give it a name (any name)\n- Password: paste your PAT\n- Hit OK\n\n![image](https://user-images.githubusercontent.com/22435398/143283802-03c968c7-c581-49ab-b5f9-59e8d92c7c8c.png)\n\n--------------------------------------------\n### Adding repository polling on GitHub\nGo to your repository on GitHub, then go to ```Settings \u003e Webhooks \u003e Add webhook```\n\n![image](https://user-images.githubusercontent.com/22435398/143284780-523f0022-3b7b-4270-81c1-06228a314b74.png)\n\n- In \u003ccode\u003ePayload URL\u003c/code\u003e add your Jenkins server address, adding ```/github-webhook/``` at the final, to look like: \u003ccode\u003ehttp://{IP Jenkins Server}:8080/github-webhook/\u003c/code\u003e\n- In \u003ccode\u003eContent type\u003c/code\u003e, choose ```application/json```\n- Leave \u003ccode\u003eSecret\u003c/code\u003e blank\n- Choose in which events you want to trigger the webhook\n- Check the \u003ccode\u003eActive\u003c/code\u003e checkbox\n- Hit \u003ccode\u003eAdd webhook\u003c/code\u003e\n  \n![image](https://user-images.githubusercontent.com/22435398/143285446-06d68ca0-175b-4e31-b7c4-30709519cefe.png)\n\n\n--------------------------------------------\n### Jenkins configuration with GitHub Polling on Push\nInside Jenkins server, click on New Item\n![image](https://user-images.githubusercontent.com/22435398/143281047-fb50f93c-d587-4522-aa63-1be1ee499382.png)\nGive the process a name, select \u003ccode\u003ePipeline\u003c/code\u003e and click on OK.\n![image](https://user-images.githubusercontent.com/22435398/143281233-783f0514-1e80-4e8e-b761-a85d04c7af04.png)\n\nAdd some configurations:\n![image](https://user-images.githubusercontent.com/22435398/143281607-1d203747-3bb9-4d4f-8baa-75dc6a74ee5d.png)\n\n\u003cb\u003eGitHub hook trigger for GITScm polling\u003c/b\u003e must be checked in order to generate the build when some event occurs in GitHub(push, pull...)\n![image](https://user-images.githubusercontent.com/22435398/143281645-7a795b67-64d8-4820-8b20-eea274378b9f.png)\n\nAdd the GitHub repository that you're going to publish, add your GitHub Credentials and select the specific branch you want to pull (or leave it blank for any).\n![image](https://user-images.githubusercontent.com/22435398/143282605-60972887-4934-41da-9e77-8b97bce54711.png)\n\nAdd some behaviours (it's needed if you want to work with submodules)\n![image](https://user-images.githubusercontent.com/22435398/143282762-4032de20-d1a8-49e8-8fc5-84137f1fe42c.png)\n\nFinally, put the name of your Jenkinsfile file and then hit Save.\n![image](https://user-images.githubusercontent.com/22435398/143282843-f93adcc4-5835-4c6b-aa77-444d729f8721.png)\n\n## Example of Jenkinsfile\n```yml\npipeline{\n    agent any\n    \n    stages{\n        stage('Run Docker Compose'){\n            steps {\n                sh \"\"\" #!/bin/bash\n                    git submodule update --init --recursive\n                \"\"\"\n                sh \"\"\" #!/bin/bash\n                    sudo docker-compose -f docker-compose-staging.yml up -d --build\n                \"\"\"\n            }\n        }  \n    }\n}\n```\n\n## Jenkins Workspace Directory\nIt is located at: ```/var/lib/jenkins/workspace```\n\n## Common errors in Jenkinsfile\n### Authentication error in Jenkins on using sudo\n```bash\nsudo su    \nvisudo -f /etc/sudoers\n```\nadd the following line at the end: ```jenkins ALL= NOPASSWD: ALL```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fguilospanck%2Fjenkins-github-polling","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fguilospanck%2Fjenkins-github-polling","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fguilospanck%2Fjenkins-github-polling/lists"}