Jenkins Interview Q&A

***** JENKINS Q&A *****

1. What is Jenkins?

Jenkins is an open-source automation server used for continuous integration and continuous delivery (CI/CD) to automate building, testing, and deploying applications.

2. What are the main features of Jenkins?

Key features include easy installation, extensible via plugins, distributed builds, support for multiple languages, and easy integration with version control systems.

3. What is a Jenkins pipeline?

A Jenkins pipeline is a set of automated steps defined in a script to build, test, and deploy an application, typically written in Groovy using a Jenkinsfile.

4. Difference between freestyle job and pipeline job?

Freestyle jobs are basic jobs with simple configuration, whereas pipeline jobs provide complex automation using code and allow multi-step workflows and stages.

5. What is a Jenkinsfile?

A Jenkinsfile is a text file that contains the definition of a Jenkins pipeline, specifying stages, steps, and other pipeline configurations.

6. Difference between declarative and scripted pipeline?

Declarative pipelines provide a simpler, structured syntax; scripted pipelines offer more flexibility using Groovy scripting for complex scenarios.

7. What are Jenkins plugins?

Plugins extend Jenkins functionality by integrating with tools like Git, Maven, Docker, Slack, and allow customization of Jenkins workflows.

8. Explain Jenkins master-slave architecture.

Master manages jobs and schedules builds. Slaves are distributed nodes that execute build tasks assigned by the master to distribute workload.

9. How do you trigger a Jenkins job?

Jobs can be triggered manually, periodically using cron, via SCM changes, build completion of another job, or through REST API calls.

10. What is a Jenkins workspace?

The workspace is a directory on the build node where Jenkins checks out the source code and performs all build and test operations.

11. What is continuous integration?

Continuous integration is a practice where developers frequently integrate code into a shared repository, and each integration is automatically built and tested.

12. Continuous delivery vs continuous deployment?

Continuous delivery ensures code is always deployable, while continuous deployment automatically releases every change passing all tests to production.

13. How do you secure Jenkins?

Security includes authentication, authorization (roles or matrix-based), SSL, restricting access to jobs, and credentials management for sensitive data.

14. Difference between Build, Build with Parameters, and Trigger builds remotely?

Build runs default job settings, Build with Parameters allows input parameters, Trigger builds remotely enables triggering via a token and API.

15. What is Jenkins Blue Ocean?

Blue Ocean is a modern UI for Jenkins pipelines providing visual representation, easier navigation, and improved user experience.

16. How to integrate Jenkins with Git?

Integration options include polling SCM, webhooks, and plugin-based triggers like GitHub or GitLab plugins.

17. Difference between polling SCM and webhook?

Polling SCM periodically checks for changes, while webhooks notify Jenkins instantly when changes are pushed.

18. How to manage Jenkins credentials?

Credentials are managed using the Jenkins Credentials Plugin to securely store usernames, passwords, tokens, SSH keys, and other secrets.

19. What is a Jenkins node?

A node is a machine in Jenkins environment on which jobs are executed. Master handles scheduling; slaves execute builds.

20. How to handle build failures in Jenkins?

Build failures can be handled by notifications, retrying builds, archiving artifacts, or using post-build actions and pipeline stages for error handling.

21. What are post-build actions?

Tasks executed after the build completes, such as sending notifications, archiving artifacts, deploying applications, or triggering downstream jobs.

22. How to schedule Jenkins jobs?

Jobs can be scheduled using 'Build periodically' with cron-like syntax or pipeline 'cron' triggers.

23. Difference between Freestyle job and Maven job?

Freestyle jobs allow custom commands for building projects; Maven jobs provide specialized integration using POM files.

24. How to backup and restore Jenkins?

Backup by copying JENKINS_HOME including jobs, plugins, credentials. Restore by placing backup into a fresh Jenkins installation.

25. What is pipeline as code?

Defining build, test, deploy steps in a version-controlled Jenkinsfile, enabling reproducible CI/CD workflows.

26. What is the difference between Jenkins and other CI tools like Travis or CircleCI?

Jenkins is self-hosted, highly extensible with plugins, and supports complex pipelines, whereas Travis/CircleCI are cloud-based with simpler configuration.

27. How to integrate Jenkins with Docker?

Using Docker plugin or pipelines, Jenkins can build images, run containers for testing, and deploy applications in Docker environments.

28. What is Jenkins agent?

An agent is a machine that executes tasks assigned by Jenkins master; it can be a permanent node or dynamically provisioned (like with Kubernetes or Docker).

29. What is the difference between a freestyle project and multi-branch pipeline?

Freestyle projects are single-job configurations; multi-branch pipelines automatically detect branches in SCM and create pipelines for each branch.

30. How to implement CI/CD using Jenkins?

By creating pipelines that automate building, testing, and deploying code with triggers from SCM, notifications, and artifact management.

31. What is the use of Jenkins Environment Variables?

Environment variables provide dynamic information like workspace, build number, job name, SCM info, and can be used in scripts or pipelines.

32. How to handle secrets in Jenkins pipelines?

Using Jenkins credentials plugin and environment injection, secrets can be securely accessed in pipelines without exposing plain text.

33. What is a Jenkins build parameter?

Build parameters allow user inputs (string, choice, boolean, password) when triggering a job to customize build behavior.

34. How to use Jenkins Shared Libraries?

Shared Libraries store common pipeline code in a separate repository for reuse across multiple Jenkins pipelines, improving maintainability.

35. What are Jenkins stages and steps?

Stages define logical divisions in a pipeline, while steps are individual tasks executed within each stage.

36. How to monitor Jenkins builds?

By using the Jenkins dashboard, build logs, notifications, email alerts, and external monitoring plugins like Prometheus or Grafana.

37. Difference between build queue and build executor?

Build queue contains jobs waiting to run; executors are slots on nodes where jobs actually run.

38. How to integrate Jenkins with testing tools?

Using plugins or pipelines, Jenkins can execute unit, integration, and functional tests with tools like JUnit, Selenium, or Cucumber.

39. What is Jenkinsfile vs pipeline script in UI?

Jenkinsfile is version-controlled code defining pipelines; pipeline script in UI is entered manually and stored in Jenkins configuration.

40. How to trigger downstream jobs in Jenkins?

Using 'Build other projects' post-build action, pipeline 'build' step, or parameterized triggers to run dependent jobs.

41. How to use Jenkins for multi-environment deployment?

By defining separate stages for dev, QA, staging, production with environment-specific configurations and approvals in pipelines.

42. What is the difference between Jenkins freestyle job and pipeline job in terms of version control?

Pipeline jobs are defined in code (Jenkinsfile) and version-controlled; freestyle jobs are configured via UI and not easily versioned.

43. What is Jenkins Distributed Builds?

Distributed builds allow multiple nodes (slaves/agents) to execute jobs in parallel, improving performance and scalability.

44. How to handle multiple branches in Jenkins pipeline?

Using Multibranch Pipeline projects that automatically create pipelines for each branch in SCM and manage branch-specific builds.

45. How to rollback deployments using Jenkins?

By maintaining previous artifact versions and creating pipeline stages or jobs that redeploy the older stable version when needed.

46. What are Jenkins Blue/Green and Canary deployments?

Blue/Green deployment runs new version on a parallel environment; Canary deployment gradually shifts traffic to the new version for testing.

47. How to integrate Jenkins with cloud platforms like AWS or Azure?

Using cloud plugins or pipelines, Jenkins can provision resources, deploy applications, and manage infrastructure on AWS, Azure, or GCP.

48. How to implement automated rollback in Jenkins pipelines?

By defining pipeline stages that track deployment status, run automated tests, and deploy previous stable artifacts if failures occur.

49. What are common Jenkins performance optimization techniques?

Techniques include using distributed builds, cleaning old workspaces, limiting concurrent builds, using pipeline libraries, and plugin management.

50. How to upgrade Jenkins safely?

Backup JENKINS_HOME, test upgrades on a staging server, verify plugin compatibility, then upgrade Jenkins and plugins in production.

***** MAVEN Q&A *****

1. What is Maven and its benefits?

Maven is a build and project management tool for Java and other languages. It simplifies builds, automates dependency management, and standardizes project structures.

2. Difference between Ant and Maven

Ant is procedural, has no lifecycle, and requires manual dependency handling. Maven is declarative, has a built-in lifecycle, uses conventions, and automatically manages dependencies.

3. What is POM, and its minimum elements?

POM (Project Object Model) is an XML file defining project info, dependencies, and build configuration. Minimum elements: project, modelVersion, groupId, artifactId, version.

4. Maven build lifecycle & its phases

Maven has three lifecycles: Clean (prepares project for build), Default (compiles, tests, packages, installs, deploys), and Site (generates project documentation).

5. Maven repositories: Local, Remote, Central

Local repository stores artifacts on developer machine. Remote repository is server-based for downloading dependencies. Central repository is the public Maven community repository.

6. Maven commands: mvn install, mvn clean, mvn site

mvn install installs artifacts to local repo. mvn clean removes generated build files. mvn site generates project documentation.

7. Dependency management & transitive dependencies

Maven automatically downloads required libraries from repositories. Transitive dependencies are dependencies of dependencies, included automatically.

8. Maven plugins and goals

Plugins extend Maven functionality (compile, test, package, document). Goals are specific tasks executed by plugins in a lifecycle phase.

9. Maven archetypes and creating a new project

Archetypes are project templates to quickly create standard project structures. Use 'mvn archetype:generate' to create a new project from a template.

10. Build profiles and activating them

Build profiles define environment-specific configurations. They can be activated via CLI, environment variables, OS, or file presence.

11. Optional and system dependencies

Optional dependencies reduce unnecessary transitive dependencies for certain features. System dependencies are provided by the JDK or system, with system scope.

12. Super POM & settings.xml file

Super POM is the default parent POM from which all POMs inherit minimal configuration. settings.xml configures Maven execution with proxies, repository locations, and credentials.

***** SonarQube Q&A *****

13. What is SonarQube?

SonarQube is a code quality management tool that performs continuous inspection of code to detect bugs, vulnerabilities, and code smells.

14. Key features of SonarQube

SonarQube provides code quality analysis, bug and vulnerability detection, code duplication detection, and integration with CI/CD pipelines.

15. What is a Quality Gate in SonarQube?

A Quality Gate is a set of conditions a project must pass to be considered high quality, such as no critical bugs and minimum code coverage.

16. What is a SonarQube Scanner?

SonarQube Scanner is a tool used to analyze source code and send results to the SonarQube server.

17. How to integrate SonarQube with Jenkins?

Using the SonarQube plugin for Jenkins; configure server and scanner in the pipeline to run analysis automatically.

***** NEXUS Q&A *****

18. What is Nexus Repository?

Nexus Repository is a repository manager that stores, manages, and distributes artifacts for build tools like Maven, Gradle, and npm.

19. Types of repositories in Nexus

Hosted repositories store your artifacts, Proxy repositories cache remote repositories, and Group repositories aggregate multiple repositories into one.

20. How to configure Nexus for Maven builds?

Update the Maven settings.xml file with the repository URL using <mirror> or <repository> tags to point to Nexus.

21. Difference between release and snapshot repositories

Release repositories store stable, versioned artifacts. Snapshot repositories store development versions that are updated frequently.

22. How to deploy an artifact to Nexus?

Artifacts can be deployed using 'mvn deploy' command or manually through the Nexus UI.

23. What is a Maven snapshot in Nexus?

A snapshot is a version under development. Nexus stores snapshots separately from release artifacts and updates them frequently.

24. How does Nexus handle security?

Nexus uses role-based access control, authentication, and permissions to secure repositories and manage user access.

25. What is a Repository Group in Nexus?

A Repository Group combines multiple repositories (hosted or proxy) into a single URL for easier access in builds.