- Jenkins server
- Docker Hub registry
- Add your Docker Hub credentials to Jenkins
- Install required plugins for Jenkins
- Configure Jenkins
- In Jenkins portal: Navigate to "New Item"
- Give "Name" to item and Chose "Pipeline"
- You can add description to the pipeline
- Then chose "Github project" and add Github repo URL
- Then in "Building Triggers" select "GitHub hook trigger for GITScm polling"
- In Pipeline select "Pipeline script from SCM", SCM is "Git" add Github repo URL, specify branch, "Script Path" is File name "Jenkinsfile"
- Configure GitHub
- In GitHub repo: Go to "Setting" -> "Webhooks"
- Payload URL: https://<UR_PUBLIC_IP>:8000/github-webhook/
You need to expose container from localhost to internet
You can use ngrok to achieve this
Run this with ngrok installed
ngrok.exe http 8000
copy link and paste to "Payload URL"
example: https://2966-93-172-72-111.ngrok.io/github-webhook/
- Content type: "application/json"
- In "Witch events would trigger?" chose "Just the push event"
- In "Secret" add API token from Jenkins
in Jenkins portal click on your user name on right top and chose "Configure"
Scroll till "API Token" and generate new
- Click on "Add webhook"
- Finely push some changes and enjoy your pipeline
- In Jenkins portal: Go to "Manage Jenkins" -> "Credentials"
- click on "global"
- Chose "Add credentials"
Docker Hub
- Chose "Username with Password"
- Fill credentials fields
ID - DockerHub-LG
password - password
username - username
- Add description
- In Jenkins portal: Go to "Manage Jenkins" -> "Plugins" -> "Available plugins"
- Search for "GitHub Integration Plugin" and install
- Search for "Docker Pipeline" and install
- Search for "Docker Plugin" and install
- In Jenkins portal: Go to "Manage Jenkins" -> "Tools"
- Scroll till Docker -> Docker installation
- Name - Docker
- Install automatically
- Chose from Docker.com