Top 45 Continuous Integration Interview Questions in Devops

You can develop good software regardless of the technology you are working on by following certain fundamental practices. One of such Practices are Continuous Integration(CI).

Here in this tutorial we are going to read about continuous Integration in DevOps.

We have also collected Essential 45 Continuous Integration (CI) Questions that may help you for your next Devops Interview. Read All Continuous Integration Questions and tutorial for any help.

Continuous Integration Interview Questions
  • Plan for code changes
  • Perform the code changes, then compile and test
  • Check the results
  • Act on the results
  • Adapt Continuous Integration to help you with seamless software development.

What is Continuous Integration?


The earlier you detect defects, the cheaper they are to fix, this is applicable for any industry you are working.

Continuous Integration (CI) is a software development practice, where developers will commit (integrate) their code changes to a shared repository frequently.

Such commits must trigger automated builds and tests, enabling quick verification of the changes at an early stage of the development cycle, rather than waiting to detect bugs after the code is completely developed.

Why Continuous Integration?


Continuous Integration does not get rid of bugs, but it does make it easier to find and remove.

When developers cultivate the habit of integrating their code changes regularly:

  • Changes will be typically small
  • Errors can be detected quickly
  • Pointing out the change that introduced an error can be done quickly

Continuous Integration – Services
Continuous Integration includes the following:

  • Source Code Control
  • Code Compile
  • Integrate Database Changes
  • Run Tests
  • Code Inspection

Source code control is the heart of Continuous Integration.
Source code must be managed using a Version Control System (VCS).

The different types are:

  • Local
  • Centralized
  • Distributed

Source Code Control – Types


Local Version Control System:

Codebase is maintained locally
Centralized Version Control System (CVCS):

Code resides on a central base
Developers:
create work branches
perform changes on the work branch
publish changes to the central base
SVN is an example of CVCS
Distributed Version Control System (DVCS):

  • Developers:
  • clone the central base into their local machines
  • create work branch from the local base
  • perform the changes in the work branch
  • merge the changes in the work branch to local base
  • synchronize the local base with the central base
  • Git is an example of DVCS

Version Control Branch Types


All the currently existing version control tools support branches or codeline.

Branch: An independent line of work that stems out from a central codebase.

Types of Branch in Continuous Integration:

  • The Main branch is known as trunk, mainline or master
  • The Release branch is used for bug fixes post user release
  • The Work Branch is used by developers for development changes
  • Every branch should have an owner.

The owner must define the branch policy (when a code should be checked in).

Mainline Branch
The Mainline branch must be stable always so that the code is in ready to deploy state.

Ready to deploy implies that the code has successfully passed tests like integration, regression, and so on.

Code in mainline is deployed to the user or production environments.

Release Branch
Change done on the release branch must flow back to the mainline.

The Release branch should never receive a change from the mainline.

It must be closed after a release from the mainline.

Work Branch
Work or development branch is where the developer compiles the code, integrates and runs tests.

Stable changes in work branches are published to the mainline.

What if your team is implementing multiple changes in parallel on the work branch?

How to Handle Parallel Changes using Continuous Integration?


Publishing to the mainline is easy when only one change is implemented at a time.

Consider a scenario when 2 developers are working on the same work branch:

Developers A and B are working on different changes simultaneously.
Developer A has partially completed the changes and merges it with the work branch.
Developer B completes the changes fully and merges it with the work branch.


Then, developer B publishes the changes to the mainline.
Accidentally, B ends up publishing the partially done changes of A to the mainline.
Publishing an incomplete code to the mainline is a violation of the mainline branch policy.
If an issue arises later, it will be hard to say whose change introduced it.


What can be done now?

Team collaboration plays a crucial role in such scenarios.

Either developer B must wait until both changes have been completed and then publish to the mainline.
Or prioritize the changes by publishing the top priority change first to the mainline. Then, merge the other change with local version control.
Avoid multiple parallel changes in the same work branch.

Merging Work Branch Conflicts


How to handle conflicts during code merge in Continuous Integration?

Developer A is using a library variable in the code changes.
Developer B completely removes references to the library and publishes it to the mainline.
Now, developer A needs to discover the conflicting change before proceeding further.

To detect conflicts at an early stage:

Merge down the code from the work branch to your development region as often as possible
Check-in changes to the work branch frequently
What if other teams are working on separate work branches that end up publishing to the mainline?

Build in Continuous Integration

Activities performed to generate, test, inspect and deploy software.

All the assets required to build like library, DLLs, configuration files are centralized into the central repository.
To maintain the central repository effectively:

Use a consistent directory structure in the central repository, which enables you to retrieve only the required files.
Create folders for design, requirement, implementation, testing, and so on.
Fetch the required files from the implementation folder for integration build.

Build Scripts in Continuous Integration
As soon as a change is moved into version control, it is a recommended CI practice to build immediately.

  • Create build scripts (using tools like Maven, Ant)
  • Execute build scripts from an IDE or command line or CI tool
  • Build scripts should not be dependent on the IDE, which means it must be executable from the CI tool if used
  • Use CI tools to automate the trigger and execute the build scripts on detecting a change.
Continuous Integration Interview Questions

Build is of 3 types in Continuous Integration, namely:

  • Private Build
  • Private Build
  • Run by the developer before committing the code changes to the local version control or work branch.

The sequence of activities performed by a developer are listed as follows:

  • Check out the code from work branch.
  • Perform the required code changes.
  • Get the latest system changes (like database changes) from central repository.
  • Run build jobs that includes execution of unit test cases.
  • Commit changes to the work branch on a successful build.
  • Integration Build – Continuous Integration Branch

    Integrates changes committed on the work branch with the mainline.
  • Ideal to run integration build on a dedicated machine.
  • Code compilation, unit test, component test, system and performance test along with inspections are executed as part of this build.

Release Build – Continuous Integration Branch


Deploys code to the production or end-user.

Includes extensive load and performance tests along with user acceptance tests.

Triggered by code changes on the mainline or release branch.

  • Build Mechanism – Continuous Integration Branch
  • On-Demand: Build initiated manually.
  • Scheduled: Build triggered based on time.
  • Poll for Changes: Build runs after a change is detected by a CI tool.
  • Event-Driven: Build triggered by version control tool based on a change.
  • Run Fast Builds
    Rapid feedback is a key factor of CI.
  • If the build runs for a longer duration, it may delay the reporting and fixing of errors. So stage the builds (split builds logically).
  • Create separate build scripts to:
  • Fetch changes from version control and compile.
    Run unit tests.
    Run automated processes like integrating the database changes, component tests or system tests, and code inspection.
    Do incremental builds (compile only the components changed) when compilation takes a longer duration. But, use it judiciously.
  • Criteria to Evaluate CI Tools
    A craftsman who wishes to practice his craft well must sharpen his tools – Chinese Proverb
  • Selecting a CI tool is highly dependent on the environment, size, and functionality of the project.

Evaluate the required tool, based on its:

  • Functionality (Essential and Extendable)
  • Compatibility with your environment (supports current build configuration and existing version control, compiles the code language)
  • Reliability
  • Longevity (choose a tool with a healthy user base and established development group)
  • Usability (easier to configure and use)

Build Tool: Essential Functionality
Code compilation
Component packaging
Program execution
File manipulation
Development test execution
Integration with Version control tool
Document generation
Deployment functionality
Code quality analysis
Extensibility to integrate plugins
Multi-platform build support
Build Execution
Version control integration
Build tool integration
Feedback
Build labeling

Continuous Integration Tools

Below are the Continuous Integration (CI) Tools :

Version Control – GitHub, Subversion

Java Build – Ant, Maven

.Net Build – NAnt, MSBuild

Java build scheduler – Jenkins, CruiseControl

Static code analysis – SonarQube, Checkstyle, PMD

Code Coverage – JCov, Clover, Serenity, Cobertura

Unit Testing – NUnit, JUnit

Functional Testing – Cucumber, Selenium

Artifact Repository – Nexus, Artifactory

Continuous Integration Interview Questions

Top 45 Trending Continuous Integration Interview Questions

(1)Git, Mercurial and Subversion are centralized version control tools.
(a)False
(b)True
Correct Answer of the above question is : (a)False
(2)Jabber is a :
(a)Messaging plugin
(b)Deployment plugin
(c)Build plugin
Correct Answer of the above question is : (a)Messaging plugin
(3)Select a CI tool based on its __.
(a)None of the options
(b)Resistability
(c)Extendability
(d)Both the options
Correct Answer of the above question is :(c)Extendability
(4)CI pipeline consists of __.
(a)Items
(b)Stages
(c)Artifacts
(d)Commitments
(e)Tickets
Correct Answer of the above question is : (b)Stages
(5)Which is the first code analysis to be executed ?
(a)style check
(b)code coverage
(c)unit test
Correct Answer of the above question is : (c)unit test
(6)Which of the following is an artifact repository ?
(a)Matrix
(b)Ansible
(c)Maven
(d)Nexus
Correct Answer of the above question is : (d)Nexus
(7)Which of these is not a valid build trigger ?
(a)manual trigger
(b)parameterized trigger
(c)downstream trigger
(d)version conrol trigger
Correct Answer of the above question is : (b)parameterized trigger
(8)Work Branch is also known as_______________________.
(a)Mainline
(b)Trunk
(c)None of the options
(d)Codeline
Correct Answer of the above question is : (d)Codeline
(9)CCMetrics is used to identify ___________.
(a)Coupling factor
(b)Incoming dependencies
(c)Code Complexity
(d)Outgoing dependencies
Correct Answer of the above question is : (c)Code Complexity
(10)It is a proven fact that reducing the CCN of code is known to reduce the number of errors or bugs in the code.
(a)False
(b)True
Correct Answer of the above question is : (a)False
(11)Private builds are executed after moving the changes to version control.
(a)True
(b)False
Correct Answer of the above question is : (b)False
(12)Efferent Coupling is a measure of ________.
(a)Code Complexity
(b)Outgoing dependencies
(c)Incoming dependencies
Correct Answer of the above question is : (b)Outgoing dependencies
(13)Build can be triggered by a version control tool.
(a)True
(b)False
Correct Answer of the above question is : (a)True
(14)Does CI pipeline need to have all the software development functionalities integrated in place ?
(1)False
(2)True
Correct Answer of the above question is : (1)False
(15)stream based version control helps to apply bug fixes to many versions of the application.
(a)False
(b)True
Correct Answer of the above question is : (b)True
(16)Commiting a code change, when the inspection fails , is perfectly fine as the code logic is working fine anyway
(a)False
(b)True
Correct Answer of the above question is : (a)False
(17)Arrange in order- A. Running Unit Test B.Running Static Code Check C.Check for Code Coverage D. Build Package
(a)BACD
(b)ABDC
(c)ACBD
(d)BADC
Correct Answer of the above question is : (a)BACD
(18)—– is a .Net build tool.
(a)NAnt
(b)Ant
(c)Maven
Correct Answer of the above question is : (a)NAnt
(19)Which of the tools is not mandated for integration in a CI pipeline ?
(a)Terraform
(b)Chef
(c)Maven
(d)Selenium
Correct Answer of the above question is : (c)Maven
(20)It is not required to assign an owner for a branch.
(a)False
(b)True
Correct Answer of the above question is : (a)False
(21)The following options are mandated for a CI pipeline, except _.
(a)Functional testing
(b)Infrastructure as Code
(c)Configuration code
(d)Application code
Correct Answer of the above question is : (d)Application code
(22)____ helps in differentiating the environments.
(a)Build scripts
(b)Configuration files
(c)Both the options
Correct Answer of the above question is : (c)Both the options
(23)_ plays a crucial role to help reduce the build duration.
(a)Pipeline metrics
(b)Both build and pipeline metrics
(c)None of the options
(d)Build metrics
Correct Answer of the above question is : (d)Build metrics
(24)It is possible to clone the central repository locally.
(a)True
(b)False
Correct Answer of the above question is : (a)True
(25)Which is NOT true about continuous integration ?
(a)Involves moving code in frequent intervals
(b)Involves moving code in large amounts
(c)Involves moving code from development to test environment
(d)Most effectively done through automation
Correct Answer of the above question is : (b)Involves moving code in large amounts
(27)Code compilation is an essential part of _.
(a)Build Tool
(b)Version control
(c)Testing Tool
Correct Answer of the above question is : (a)Build Tool
(28)The following are CI tools, except __.
(a)Travis CI
(b)Teamcity
(c)Maven
(d)Jenkins
Correct Answer of the above question is : (b)Teamcity
(29)In a normal scenario, software from _ is deployed to production.
(a)All of the options
(b)Release branch
(c)Work branch
(d)Master branch
Correct Answer of the above question is : (d)Master branch
(30)Which is not a CI practice ?
(a)Run fast builds
(b)Deploy to production
(c)Stage Builds
(d)Commit frequently
Correct Answer of the above question is : (b)Deploy to production
(31)How are component dependencies injected in a workflow ?
(a)Run unit test and build package
(b)Parallel trigger components and build package
(c)Build package first and then perform the remaining tasks
(d)Use sequence triggers
Correct Answer of the above question is : (c)Build package first and then perform the remaining tasks
(32)Trunk is also known as _______
.
(a)Codeline
(b)Feature Branch
(c)Work Branch
(d)Mainline
Correct Answer of the above question is : (d)Mainline
(33)_ is an independent line of work.
(a)Branch
(b)None of the options
(c)Code
Correct Answer of the above question is : (a)Branch
(34)Git, Mercurial, and Subversion are centralized version control tools.
(a)False
(b)True
Correct Answer of the above question is : (a)False
(35)Private builds can be triggered automatically.
(a)False
(b)True
Correct Answer of the above question is : (a)False
(36)Git is a ________________
version control system.
(a)Centralized
(b)Distributed
(c)Local
(d)None of the options
Correct Answer of the above question is : (b)Distributed
(37)Complexity of a code is determined based on .
(a)Cyclomatic Complexity Number
(b)Number of source lines of code
(c)Efferent Coupling
(d)Time taken to perform inspection
Correct Answer of the above question is : (a)Cyclomatic Complexity Number
(38)____
is a code coverage tool.
(a)NUnit
(b)Cobertura
(c)None of the options
(d)Jenkins
Correct Answer of the above question is : (b)Cobertura
(39)Trunk is also known as ______.
(a)Feature Branch
(b)Mainline
(c)Codeline
(d)Work Branch
Correct Answer of the above question is : (b)Mainline
(40)Subversion (SVN) is a distributed version control system.
(a)False
(b)True
Correct Answer of the above question is : (a)False
(41)Release branches are created for solving bugs detected after the application is released to the user.
(a)False
(b)True
Correct Answer of the above question is : (b)True
(42)It is perfectly acceptable to commit a code change, though the code inspection has failed.
(a)True
(b)False
Correct Answer of the above question is : (a)True
(43)The minimum number of test inputs required to test the execution of a program is determined by __.
(a)Coupling
(b)CCN
(c)None of the options
Correct Answer of the above question is : (c)None of the options
(44)Jabber is a :
(a)Build plugin
(b)Messaging plugin
(c)Deployment plugin
Correct Answer of the above question is : (b)Messaging plugin
(45)Activities that are part of continuous integration______________.
(a)Tests
(b)Code Build
(c)Inspection
(d)All of the Options
(v)Version Control
Correct Answer of the above question is : (d)All of the Options
(46)Which is NOT a benefit of CI ?
(a)Issues can be identified and addressed quickly
(b)The integration process is faster
(c)Bugs and defects no longer occur
(d)Productivity increases
Correct Answer of the above question is : (c)Bugs and defects no longer occur