Day 29 Task: Jenkins Important interview Questions.

Day 29 Task: Jenkins Important interview Questions.

  1. What’s the difference between continuous integration, continuous delivery, and continuous deployment?

  • Continuous Integration is an approach of testing each change to codebase automatically, whereas Continuous Delivery is an approach to obtain changes of new features, configuration, and bug fixes. On the other hand, Continuous Deployment is an approach to develop software in a short cycle.
Continuous IntegrationContinuous DeliveryContinuous Deployment
CI is an approach of testing each change to codebase automatically.CD is an approach to obtain changes of new features, configuration, and bug fixes.CD is an approach to develop software in a short cycle.
CI refers to the versioning of source code.CD refers to the logical evolution of CI.CD refers to automated implementations of the source code.
CI focuses on automation testing to determine that the software has no errors or bugs.Focuses on releasing new changes to your clients properly.Emphasis on the change in all stages of your production pipeline.
CI is performed immediately after the developer checks-in.In CD, developed code is continuously delivered until the programmer considers it is ready to ship.In CD, developers deploy the code directly to the production stage when it is developed.
It helps you to identify and rectify issues early.It allows developers to check software updates.It enables you to rapidly deploy and validate new features and ideas.
It uses unit tests.It uses business logic tests.Any testing strategy is performed.
Development team sends continuous code merging requests even when the testing process is running.You deliver code for review that can be batched for release.Deploy code using an automated process.
You require a continuous integration server to monitor the main repository.You require a strong foundation in continuous integration.You need a good testing culture.

2.Benefits of CI/CD?

-Smaller Code Changes

-Fault Isolations

-Faster Mean Time To Resolution (MTTR)

-More Test Reliability

-Faster Release Rate

-Reduce Costs

-Easy Maintenance and Updates

3.What is meant by CI-CD?

CI/CD is the combined practices of continuous integration (CI) with continuous delivery or continuous deployment (CD). The purpose of CI/CD is to allow development teams to deliver code changes more frequently and reliably.

4.What is Jenkins Pipeline?

In Jenkins, a 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.

5.How do you configure the job in Jenkins?

Step 1: Create a New Freestyle Project

Click the New Item link on the left-hand side of the Jenkins dashboard.

Enter the new project's name in the Enter an item name field and select the Freestyle project type. Click OK to continue.

Under the General tab, add a project description in the Description field.

Step 2: Add a Build Step

Enter the commands you want to execute in the Command field. For this tutorial, we are using a simple set of commands that display the current version of Java and Jenkins working directory:

Step 3: Build the Project

6.Where do you find errors in Jenkins?

In console like below!

7. In Jenkins how can you find log files?

sudo cat /var/log/jenkins/jenkins.log unless customized in org.jenkins-ci.plist.

8.Jenkins workflow and write a script for this workflow?

Groovey Syntax:

Output:

9.How to create continuous deployment in Jenkins?

The main part of continuous deployment to make sure that the above entire process is automated. Jenkins provides various plugins for all these things. One of them is "Deploy to container" plugin, which was seen in earlier sections.

Step 1: Go to the Jenkins Dashboard and select New Item.

Step 2: Give the Item name and choose Freestyle project option. Here I have given the item name "demo". Click on OK button.

Step 3: In this example, we are keeping it simple and just using to print HelloWorld.

Select the Git option and enter the GitHub repository of your HelloWorld program in the Repository URL section.

Step 4: Select the Execute Windows batch command option from the add build step button and give the command to run your java program.

Step 5: Click on Apply then Save button.

Step 6: Now, go to your previously created Helloworld project and click on the Configure option.

Step 7: In the Project configuration, select the Add post-build action and choose Build other projects option.

Step 8: In the Projects to build option, enter the "demo" as the project name to build. You can leave the other option as the default. Click on Apply then the Save button.

Step 9: Now, build the HelloWorld project. To do that, click on the Build Now option

Step 10: Click on the latest build and select the Console Output option.

10.How to build job in Jenkins?

  1. Step 1: Create a New Freestyle Project. Click the New Item link on the left-hand side of the Jenkins dashboard. ...

  2. Step 2: Add a Build Step. Scroll down to the Build section. ...

  3. Step 3: Build the Project.

11.Why we use pipeline in Jenkins?

Jenkins pipeline allows us to define a complete list of events that happen in the code lifecycle. Starting from the build, to testing and deployment.

We can use a set of plugins that help in the implementation of certain processes as a continuous delivery pipeline. Where pipelines are defined using code by using groovy language to define the processes that would run in the pipeline.

To implement pipeline as code, a Jenkinsfile needs to be present at the project’s root repository.

Jenkinsfile supports two different syntax:

  • Declarative

  • Scripted

Declarative pipeline was a recent release and provides better syntax support over the scripted pipelines.

12.How will you handle secrets?

Jenkins secrets, also known as credentials, are used for various authentication and authorization purposes and can include things like passwords, API keys, and private SSH keys.

When it comes to managing these secrets, it’s important to understand there are two scopes in Jenkins: system-wide and job-specific. System-wide secrets are available to all jobs and projects within a Jenkins instance, such as credentials for a shared database or Git repository. Job-specific secrets are only available to a specific job or project and are typically used for specific tasks, like deploying to a particular environment.

One way to configure Jenkins secrets is through the Jenkins web interface. To do this, navigate to the "Credentials" page in the Jenkins settings.

As attached screenshots below we can store the credentials by using Keys and environment variables.

Here is the e.g. for dockerhub credentials stored in jenkins secret key.

Syntax:

13.Explain diff stages in CI-CD setup

  1. The trigger

  2. Code checkout

  3. Compile the code

  4. Run unit tests

  5. Package the code

  6. Run acceptance tests

  7. Delivery or Deployment

14.Name some of the plugins in Jenkins?

Git Plugin

Git is one of the most installed Jenkins add-ons available on its repository. It allows you to integrate Jenkins with GitHub and transfer GitHub repository data to the Jenkins machine easily

Kubernetes Plugin

Kubernetes is another widely used plugin in Jenkins. It allows you to run all the dynamic agents in a Kubernetes cluster. This plugin creates a Kubernetes Pod for each agent getting started and stopped once the build is finished.

Jira Plugin

The Jira plugin integrates Jenkins with Atlassian Jira Software. You can work with both the Cloud and Server versions with this Jenkins plugin. But you need to use a Jira service account instead of a Jira personal account to install this plugin.

Docker Plugin

The Jenkins cloud plugin for Docker is the most effective solution for DevOps engineers to integrate Jenkins with Docker. It allows you to dynamically provision the Docker containers and run those as Jenkins agent nodes

Maven Integration Plugin

Jenkins has native Maven support, although you may need deeper integration if you use it. This Jenkins plugin is available independently and offers greater Jenkins integration for Apache Maven projects.

Blue Ocean Plugin

According to the Blue Ocean functionalities, Jenkins' interface was recently updated. Blue Ocean, designed in tandem with Jenkins Pipeline and compatible with the Freestyle jobs.

Amazon EC2 Plugin

Amazon EC2 plugin lets Jenkins start up new EC2 or Eucalyptus agents on demand and shut them down when they are no longer needed.

Pipeline Plugin

The Jenkins 2.0 version came with the Jenkins Pipeline plugin. It's an extremely useful tool for DevOps teams. A pipeline is, in fact, a collection of plugins that are used to make pipelines for continuous integration.

SonarQuobe

SonarQuobe is an open-source tool used for continuous code quality inspection. The Jenkins monitoring plugin allows you to integrate SonarQube into Jenkins so that you can easily analyze a code while running a Jenkins job that comes with SonarQuobe execution.

Metrics Plugin

Metrics is a Java library that offers a toolkit to measure the performance metrics of the critical components in your production environment. The Metrics Jenkins plugin exhibits the same API of Metrics as all the other Jenkins plugins.

15.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.

Thank you for reading!! Hope you find this helpful.

#day29#90daysofdevops#devopscommunity#

Always open for suggestions..!!