Here are some Jenkins-specific questions related to Docker that one can use during a DevOps Engineer interview:
Questions
What’s the difference between continuous integration, continuous delivery, and continuous deployment?
Continuous Integration - It is the process of automating the steps for developers by building and testing the code before merging it into the commit branch.
Developers push the code in small increments to Version Control System which is GitHub, i.e then build through some tools like Maven and then tested.
Continuous Delivery and Deployment - It is the process of releasing the final version of the code to the server environment may be it is in Production.
The basic difference between Continous Delivery and Continous Deployment is, In Continous Delivery, there is a need for manual intervention to push the final code into Production or a higher environment whereas in Continous Deployment the final code is deployed automatically through the pipeline setup.
Benefits of CI/CD
it enhances the overall code quality. It enables developers to integrate their code into a common repository in small batches. Through this repository, developers can share their builds with the entire team rather than working in isolation. Now, the whole team can collaborate for thorough detection and fixation of the most severe bugs.
Using CI/CD, the code changes can be tested quickly once they are integrated. Such an approach is very beneficial when direct communication is a roadblock or when teams are spread across remote locations.
Detecting the root cause of a fault and then pointing out the exact location of the fault is one of the most proclaimed benefits of CI/CD.
Using a CI/CD pipeline limits the potential impact and loss that a deployment problem can cause by allowing it to be deployed during non-critical business hours.
Regular maintenance and updates are the backbone of making a great product, and this is one of the great benefits of CI/CD. It ensures that release cycles are shorter and targeted, which blocks fewer features that aren’t ready for release. In a CI/CD pipeline, maintenance is usually done during non-business hours, saving precious time for the entire team.
What is meant by CI-CD?
CI-CD stands for Continous Integration-Continous Deployment where the code is pushed by the developer to the Version control system and then deployed on the server continuously.
What is Jenkins Pipeline?
A Jenkins pipeline is a collection of events or jobs which are interlinked with one another in a sequence.
It is a combination of plugins that support the integration and implementation of continuous delivery pipelines using Jenkins.
In other words, a Jenkins Pipeline is a collection of jobs or events that brings the software from version control into the hands of the end users by using automation tools. It is used to incorporate continuous delivery in our software development workflow.
A pipeline has an extensible automation server for creating simple or even complex delivery pipelines "as code", via DSL (Domain-specific language).
How do you configure the job in Jenkins?
Go to Jenkins dashboard and click on the new item. Then select freestyle project.
Provide the details in general settings.
Go to Build environment and then Build step. Write the required code that can be shell commands, batch files, etc.
Click on build now to create the project, or set up automatic triggers to run it based on events such as code changes or scheduled builds through webhook.
Now, check the console output of the build and then you can navigate to the web URL to check the application.
Where do you find errors in Jenkins?
I have faced errors while integrating Jenkins with GitHub. There was a credential error because the correct private token generated needs to be configured in the source code management section.
The shell commands should be written which should be having proper permission given on the server. I have faced an error here which I prevented by using sudo <command>, else you can provide a proper group to the user.
Plugins should be installed while executing a pipeline. I have faced an error which I solved by installing Docker-Compose, Git, and Docker plugins according to the project requirement.
In setting up the Master-Slave configuration, I faced issue in the integration of Agent. The solution is to install all the required plugins, permissions and installation in the Slave server.
In Jenkins how can you find log files?
To view the Jenkins logs in Linux, we can use the following command:
$ sudo cat /var/log/jenkins/jenkins.log
We can also view the logs on a Jenkins server from the Jenkins dashboard.
Start by logging into your Jenkins web interface -> Manage Jenkins -> System Log.
Jenkins workflow and write a script for this workflow?
Jenkins workflow which is otherwise known as Jenkins Pipeline is used to create a complete build step through Groovy language. It allows users to create a pipeline containing different stages which contain different steps to be performed.
Let's write a script for a workflow.
How to create a continuous deployment in Jenkins?
First, create a pipeline for your application and set up the environment.
Provide the necessary build stages with steps.
Configure the webhook on GitHub.
Make sure to make the enable the Git hook in Jenkins configure section.
Now when any changes are made in the code the build automatically gets triggered to build and deploy the code.
How build a job in Jenkins?
Log in to the Jenkins dashboard and navigate to create a new item.
create a freestyle project or pipeline for your application.
Configure the specifications of the project by enabling features.
Write the appropriate groovy or shell script required to run the project.
Click on Save and then build now.
Why do we use pipelines in Jenkins?
It is a combination of plugins that supports the integration and implementation of continuous delivery pipelines. It has an extensible automation server to create simple and complex delivery pipelines as code. A Pipeline is a group of events interlinked with each other in a sequence.
Is only Jenkins enough for automation?
No, many tools need to be configured to have smooth automation in DevOps.
Jenkins puts focus only on automating the project pipeline from building a code to deploying a code. But, in order to have fully automation there are tools like Ansible, Terraform, Chef,etc.
How will you handle secrets?
1. One-Time Passwords (OTPs)
One-time passwords help prevent user account takeovers by ensuring that a username-password combination can not be used more than once. While the account retains the username throughout, the user is sent an OTP every time they log in. This keeps Jenkins administrators’ and users’ accounts safe, preventing secrets from being exposed to unwanted individuals.2. Avoid Hard-Coding Secrets
Remove any secrets that have been hardcoded into CI/CD configuration and Jenkins files. This keeps sensitive credential information away from the pipeline, making it inaccessible to malicious actors.3. Reduce Attack Surface by Storing Secrets in Multiple Jenkins Files
Storing secrets in multiple files helps enforce the principle of least exposure for credentials. This makes credentials available to the minimum number of applications and users possible.4. Use Authorization Controls to Manage Secrets Permissions
Developer teams should configure security checks to ensure the application requesting resource access has the properties of a valid application. These applications should be able to access various resources based on permissions assigned in RBAC policies.5. Follow the Principle of Least Privilege
Only grant permissions to applications that absolutely need access to secrets within the pipeline. Teams should consistently audit permissions to maintain the principle of least privilege throughout the pipeline’s lifecycle.Explain diff stages in CI-CD setup.
Source Code Management: GitHub needs to be integrated with Jenkins or any CI-CD tool to fetch the source code from a remote repository.
Build steps: The shell commands or the Groovy pipeline code are written to build the code. For example, this can be used to create docker images.
Test: Some automated tests are run to check if the code is meeting the requirement.
Deploy: If the code passes all test cases it is deployed to Production.
Monitoring: To check the health status of the instance or the application some monitoring tools are used like Grafana, Prometheus, etc. This would help to determine the issue which can be fixed quickly.
Name some of the plugins in Jenkins.
Git Plugin
Docker plugin
Docker-compose plugin
Kubernetes plugin
Ansible Plugin
GitHub Plugin
Thanks for reading my article. Have a nice day.
WRITTEN BY Biswaraj Sahoo --AWS Community Builder | DevOps Engineer | Docker | Linux | Jenkins | AWS | Git | Terraform | Docker | kubernetes
Empowering communities via open source and education. Connect with me over linktree: linktr.ee/biswaraj333