Advertise with Us!
We have a variety of advertising options which would give your courses an instant visibility to a very large set of developers, designers and data scientists.View Plans
The tag line of Jenkins, “Build great things at any scale” aptly describes what Jenkins does. You might have read in many blogs and articles about how Jenkins helps in continuous integration thereby helping developers and testers work in tandem to create a robust software. But what is continuous integration?
A Quick Overview
In a traditional software life cycle, developers first develop an entire module and it goes for testing after sanity checks. The testers are free during the development cycle but eventually get overloaded if a lot of issues are found later on. This leads to chaos, last minute changes and breaking of best practices. With continuous integration, developers commit multiple codes changes every day. It is then possible for testers to test and detect problems in the application early on.
Jenkins is one such awesome continuous integration tool written in Java, that allows developers to integrate their changes into the project. Jenkins takes care of the rest of the process of build, deployment, testing, and analysis by automating it. The whole software development cycle now becomes a faster and smoother process.
How does Jenkins do it?
A simple answer – plugins! There are thousands of plugins available. If you don’t find the one you need, you can code it yourself and share it with the community for greater benefit. The Jenkins community is great with loads of support and tools. Some cool features of Jenkins are –
- An extensible automation server, that helps with continuous integration and continuous delivery
- Open source – great for anyone to start practicing with their own setup
- Easy to install, set up and configure
- Use it with thousands of plugins to enhance the usability of software applications
- Can be used across platforms as it is coded in Java
Jenkins Interview Questions
When it comes to interview questions, the interviewer will probably start by asking basic questions like “what is Jenkins”, “What are the features of Jenkins”, advantages, a little about installation and so on. However, as he understands your level of knowledge, he will probably increase the difficulty level of the questions. Be crisp in your answers.
Whether you are new to Jenkins or an experienced programmer with some hands-on, our comprehensive list of questions will help you crack any Jenkins interview. Starting from the basic level, the difficulty of questions will gradually increase as we go on to the last question.
Question: What is Jenkins and why is it used?
Answer: Jenkins is a continuous integration (CI) tool for real-time testing and reporting of smaller builds in a large chunk of code. It is written in Java. It is used because it helps developers and testers work in tandem to detect and close defects early in the software development lifecycle and encourage automated testing of builds.
Question: List some features of Jenkins.
Answer: Features of Jenkins are –
- Free and open source
- Excellent community and documentation
- Exhaustive set of plugins and integrations
- Easy to set up, install and use on any platform because it is based on Java
- Supports distributed builds due to master-slave architecture, thus reducing the load on the CI server
Question: What are the advantages of using Jenkins?
Answer: Advantages of Jenkins are –
- Provides great collaboration between development and operations team, making it into a single DevOps team
- Code errors can be detected as early as possible.
- Code deployment is easy and happens in minutes, along with the generation of reports.
- Automation of integration work, thereby reducing the number of integration issues.
Question: How did Jenkins come into existence?
Answer: Originally called Hudson, Jenkins came into existence when Oracle took over the ownership to continue development of the product, by renaming it as Jenkins.
Question: How is continuous integration achieved using Jenkins?
Answer: Here are the steps –
- All the developers commit their source code changes to the shared Git repository.
- Jenkins server checks the shared Git repository at specified intervals and detected changes are then taken into the build.
- The build results and test results are shared to the developers
- The built application is displayed on a test server like Selenium and automated tests are ran.
- The clean and tested build is deployed to the production server.
Here is a diagram that clearly represents these steps –
Question: Do you know any other continuous integration tools? How is Jenkins better than any of those?
Answer: There are many other CI tools, the prominent ones being –
- Circle CI
- Travis CI
There are many more. We cannot say if Jenkins is better than each because each have their own unique features. For example, TeamCity offers great .NET support but is complex and costly, Travis CI is free just like Jenkins and has good documentation too. Bamboo offers efficient and faster builds but is not completely free and so on.
Question: What is DevOps and in which stage does Jenkins fit in?
Answer: DevOps is a software development practice which blends software development (Dev) with the IT operations (Ops) making the whole development lifecycle simpler and shorter by constantly delivering builds, fixes, updates, and features. Jenkins plays a great role because it helps in this integration by automating the build, test and deployment process.
Question: What are the system requirements to install Jenkins?
Answer: The minimum configuration required is –
- 256MB of RAM
- 1 GB of drive space
- Web browser
Question: How do you install Jenkins?
Answer: To install Jenkins, make sure the following are installed –
- Java (version 8)
- Apache Tomcat (version 9)
Download the Jenkins war file and deploy it using Tomcat. You can choose to install the plugins suggested by Jenkins during the installation itself. Once the installation is done, you will be able to see the Jenkins dashboard.
Question: Give some important plugins in Jenkins.
Answer: Here you go –
- Maven 2
- Amazon EC2
- Copy artifact
- Green Balls
- HTML Publisher
Question: What is Groovy?
Answer: Groovy from Apache is a language for Java platform. It is the native scripting language for Jenkins. Groovy-based plugins enhance Jenkins with great interfaces and build reports that are dynamic and consistent.
Question: Give a simple use case/scenario to explain how Jenkins works.
- Let us say a developer is working on some code changes and eventually commits them to the repository.
- Jenkins server, which constantly checks for changes in the repository, detects the change and pulls the changes to trigger a build.
- The build can fail, in which case the developer is informed with reports.
- If the build passes, it is deployed on to the test server.
- Once the testing is complete, a test report is generated and sent to the developers. This process continues till all the tests are successful, after which code is deployed to production.
Question: Can you start Jenkins using command line? How?
Answer: Yes, using jenkins.exe start
Question: What are the SCM tools that Jenkins supports?
Answer: The SCM or Source Code Management tools Jenkins supports are SVN, Clearcase, CVS, Git, AccuRev, Perforce, RTC, Mercurial.
Question: What is a job in Jenkins?
Answer: A job or build job is a task or step in the entire build process. It could be compiling the source code, running unit tests, deploying the application to the web server and so on.
Question: How can you create a job?
Answer: On the dashboard page, you can just select a ‘New Job’. When you create a job, you can choose options such as the SCM, triggers to control, the build script and notifications.
Question: What is meant by Jenkins pipeline?
Answer: A pipeline is a group of interlinked jobs done one after the other in a sequence. To integrate and implement continuous delivery pipelines, Jenkins pipelines provides a combination of plugins. The instructions to be performed are given through code. A continuous delivery pipeline can be represented as –
Question: What are the types of pipelines in Jenkins?
Answer: There are 3 types –
- CI CD pipeline (Continuous Integration Continuous Delivery)
- Scripted pipeline
- Declarative pipeline
Question: What syntax does Jenkins use to schedule build job or SVN polling?
Answer: The cron syntax.
Cron syntax is represented using five asterisks each separated by a space. The syntax is as follows – [minutes] [hours] [day of the month] [month] [day of the week]. Example, if you want to set up a cron for every Monday at 11.59 pm, it would be
59 11 * * 1
Question: Have you created a build job in Jenkins? Explain how to do it.
Answer: Yes. The simple steps are –
- Click on New Item on the Dashboard.
- Select the freestyle project option
- Specify the details of the job like SCM, build triggers, advanced options etc…
- It is important to specify the location of files that should be built.
- Once all the settings are marked, click on ‘Add build step’ and select the appropriate option. For example, if you want to build a file, select the file name along with the build command.
- Click on Build now for saving the build and doing a test run.
Question: How does Jenkins authenticate users?
Answer: There are 3 ways –
- The default way is to store user data and credentials in an internal database.
- Configure Jenkins to use the authentication mechanism defined by the application server on which it is deployed.
- Configure Jenkins to authenticate against LDAP server.
Question: How can you use a third-party tool in Jenkins?
Answer: Let us say we want to use the third-party tool Node.
- First make sure Node is installed.
- Though the Jenkins admin console, install the Jenkins plugin for node.
- Go to manage in the admin console and configure the settings on the Tools tab.
- You can add any configured nodeJS tool to your build job in a pipeline
For different third-party tools, the procedure may vary slightly, because of the difference in configuration settings.
Question: What is an agent?
Answer: Agent specifies the execution point for a particular stage in the pipeline or the entire pipeline itself.
Question: How do you define parameters in Jenkins?
Answer: A build can take several input parameters to execute. For example, if you have multiple test suites, but you want to run only one. You can set a parameter to decide which one should be run. To have parameters in a job, you need to specify the same while defining the parameter. The parameter can be a string, file or custom.
Question: What are the ways to configure Jenkins node agent to communicate with Jenkins master?
Answer: There are 2 ways to start the node agent –
- Browser – if Jenkins node agent is launched from a browser, a JNLP (Java Web Start) file is downloaded. This file launches a new process on the client machine to run jobs.
- Command line – to start the node agent using the command line, the client needs the executable agent.jar file. When this file is run, it launches a process on the client to communicate with the Jenkins master to run build jobs.
Question: What is a trigger? Give an example of how the repository is polled when a new commit is detected.
Answer: Triggers define when and how pipelines should be executed.
When Jenkins is integrated with an SCM, for example, Git, the repository can be polled every time there is a commit.
- The Git plugin should be first installed and set up.
- After that, you can build a trigger that specifies when a new build should be started. For example, you can create a job that polls the repository and triggers a build when a change is committed.
Question: What is the use of JENKINS_HOME directory?
Answer: All the settings, logs and configurations are stored in the JENKINS_HOME directory.
Question: What is a backup plugin? Why is it used?
Answer: This is a useful plugin that backs up all the critical settings and configurations to be used in the future. This is especially useful when there is a failure so that we don’t lose the settings.
Question: If your project build is broken, what should you do?
Answer: There are 2 ways to resolve a broken build –
- Open the console and double check if all the files are taken. If any changes are missing, place them correctly.
- Replicate the problem on your local set up to debug and fix the issue.
Question: Let us say, you have a pipeline. The first job was successful, but the second failed. What should you do next?
Answer: You can restart the pipeline from the point where it failed by doing ‘restart from stage’.
Question: How do you move or copy Jenkins from an old server to a new one?
Answer: All the configurations, settings are stored in the JENKINS_HOME (/var/lib/Jenkins) directory. You should copy the entire home directory to the new server. To do so, you can use the command ‘rsync’.
Question: What is the Git plugin?
Answer: Git plugin is used when you are using Git as the repository.
Question: What is Maven? What is the benefit of integrating maven with Jenkins?
Answer: Maven is a build management tool. Using a simple pom.xml, one can configure all the dependencies needed to build, test and run the code. Maven manages the full lifecycle of a test project. Once integrated with Jenkins, the maven Webdriver will build the project and execute all tests efficiently.
Question: Have you run automated tests on Jenkins? How is it done?
Answer: Yes. Automated tests can be run through tools like Selenium or maven. Developers can schedule the test runs. Jenkins displays the test results and sends a report to the developers.
Question: What is Kubernetes? How can you integrate Jenkins with Kubernetes?
Answer: Kubernetes is a container orchestration tool. With Kubernetes, one can create multiple container instances to achieve more fault tolerance. You can use the Kubernetes deploy plugin to use it with Jenkins for continuous deploy.
Question: Do you know about cloud computing? How can Jenkins fit into a cloud computing environment? Explain with an example.
Answer: Let us take the example of AWS cloud service. Cloud computing services use the CI/CD model so that they can push their work to the customers and constantly receive feedback. Jenkins is used to automating the CI/CD pipelines. For example, a lot of Jenkins plugins are available for many of the AWS services like Amazon EC2 and ECS.
Jenkins is a powerful tool and a happening one. Before your interview, do try writing some simple scripts and know about the most popular plugins that Jenkins supports. For example, Amazon EC2, Git, Kubernetes, Azure, pipeline, SCM, dashboard view, etc… With the above set of questions, you are sure to crack the interview and gain a good knowledge of this super easy and extremely useful CI tool.
If you are searching for more interview questions for your preparation then here you can check out the best course that will help you to prepare for Jenkins Interviews: Jenkins 2 Bootcamp: Fully Automate Builds to Deployment 2019.
If you are looking for paperback interview books, then you can checkout with these great programming questions and answers book: 189 Programming Questions and Solutions.
People are also reading: