DevOps

Jenkins

Pipelines, Jenkinsfile, plugins, agents, declarative vs scripted pipelines, Blue Ocean, troubleshooting builds

22 interview questions·
Mid-Level
1

What is a Jenkinsfile?

Answer

A Jenkinsfile is a text file containing the definition of a Jenkins pipeline, stored in the project repository. It allows versioning the pipeline configuration with the source code, facilitating traceability and collaboration. Using a Jenkinsfile with the Pipeline as Code approach is a best practice recommended by Jenkins.

2

What is the main difference between a declarative and scripted pipeline in Jenkins?

Answer

Declarative pipelines use a structured and predefined syntax with mandatory sections like agent and stages, offering a simpler and more readable approach. Scripted pipelines use pure Groovy code, offering more flexibility but requiring programming expertise. For most cases, declarative is recommended for its simplicity and maintainability.

3

What is the purpose of the agent directive in a declarative Jenkinsfile?

Answer

The agent directive specifies where and how the pipeline should execute. It can be defined globally for the entire pipeline or individually per stage. Options include any to run on any available agent, none to define specific agents per stage, or label to target agents with specific labels. Properly configuring agents allows optimizing resource usage and build performance.

4

What is the role of the stages section in a declarative pipeline?

5

How to manage credentials securely in a Jenkinsfile?

+19 interview questions

Master DevOps for your next interview

Access all questions, flashcards, technical tests, code review exercises and interview simulators.

Start for free