Monday, October 7, 2019

How to configure webhooks in GitHub and trigger jobs in Jenkins - webhook example GitHub - How to Integrate GitHub with Jenkins?

Webhooks allows developers to triggers jobs in CI server (such as Jenkins) for every code changes in SCM. In this article, we will learn how to trigger Jenkins jobs instantly for every code change.


Pre-requisites:

Make sure you install GitHub integration plug-in in Jenkins

1. Go to Jenkins, Create a job. If you already have a existing job, click on configure. Go to build triggers section and choose the below option - GitHub hook trigger for GitScm pooling.


2. Now go to GitHub, choose your repository. Click on settings, Webhooks.

3. Click on Add web hook.

4. You need to enter Jenkins URL & add /github-webhook/ in the end
http://jenkins_public_dns_name:8080/github-webhook/

5. Now enter payload URL as Jenkins URL, select just push event, click on active. Click on Add webhook
6. After you created, click on webhooks.

7. Click on recent deliveries and you should get response 200 as below:

8. Now go and make some code changes in your repo in GitHub.

9. If you look in Jenkins, you will see job is getting triggered immediately.


You can watch these steps on my YouTube channel as well, please see below:

Docker Interview Questions - Popular Docker Interview Questions


Docker Interview Questions - Popular Docker Interview Questions

1. What is the difference between Docker image and Docker container?

Docker container is simply an instance of Docker image.
A Docker image is an immutable file, which is a snapshot of container. We create an image with build command. Docker image contains all your application code along with all the dependencies packaged into this snapshot.

When we use run command, an Image will produce a container.

In programming language, an Image is a Class and a Container is an instance of the class.

2.  Can we run multiple apps on one server with Docker?
Yes, theoretically we can run multiples apps on one Docker server. But in practice, it is better to run different components on separate containers.
With this we get cleaner environment and it can be used for multiple uses.

3. How does docker client communicates with Docker daemon?

Docker client or command line interface, communicated with Docker daemon through APIs. 

    4.     How to enable IPV6 in Docker
Edit /etc/docker/daemon.json and set the ipv6 key to true.
{
  "ipv6": true
}
Save the file.
Reload the Docker configuration file by executing the below command:
systemctl reload docker


   5. How to copy files inside Dockerfile?
     Use COPY command
     For e.g.,
COPY app.py /usr/src/app/

6. How do you see running container in Docker?
docker ps command

7. How do you see all the containers?
docker ps -a command will show all the containers..

8. How to create directory inside Dockerfile?
mkdir -p /var/www/app
or  
WORKDIR /var/www/app 

      9. What are the benefits of using Docker?
      Docker is a very powerful tool. Some of the main benefits of using Docker are as follows:
   
       I. Utilize Developer Skills : With Docker we maximize the use of Developer skills. With Docker  there is less need of build or
release engineers. Same Developer can create software and wrap it in one single file.
       II. Standard Application Image : Docker based system allows us to bundle the application software and Operating system files in a
single Application Image that can be deployed independently.

       III. Uniform deployment : With Docker we can create one package of our software and deploy it on different platforms seamlessl y
 
      10. What happens when you stop the container? Will you loose the data?
You won’t lose any data when Docker container exits. Any data that your application writes to the container gets preserved on the disk until you explicitly delete the container. The file system for the container persists even after the container halts.