Jenkins Interview Questions with Answers and Code Examples
Basic (1–15)
1. What is Jenkins?
Jenkins is an open-source automation server for building, testing, and deploying software.
2. How do you install Jenkins?
Jenkins can be installed via native system packages, Docker, or running as a standalone Java application.
3. What is a Jenkins pipeline?
A pipeline is a series of steps that define a CI/CD workflow in Jenkins, either declaratively or scripted.
4. What are freestyle projects?
Traditional Jenkins jobs configured via GUI for basic build steps.
5. What is the difference between Declarative and Scripted Pipeline?
Declarative uses a simplified syntax with pipeline {}
; Scripted is Groovy-based and more flexible.
6. How do you create a simple Declarative pipeline?
7. What is a Jenkinsfile?
A text file stored in source control that defines the pipeline.
8. How do you trigger a Jenkins job?
Via SCM commit hooks, scheduled cron jobs, or manual triggers.
9. How do you configure environment variables in Jenkins pipeline?
10. How do you run shell commands in Jenkins pipeline?
11. What is the purpose of the agent
directive?
Specifies where the pipeline or stage will run, e.g., any available node or a specific label.
12. How do you checkout source code in a pipeline?
13. How do you archive artifacts?
14. How do you pass parameters to a Jenkins job?
15. How to send email notifications?
Use the emailext
plugin in pipeline:
Intermediate (16–35)
16. What are Jenkins plugins?
Plugins extend Jenkins functionality like source control, notifications, build steps, etc.
17. How to define parallel stages?
18. How do you use credentials in Jenkins?
19. How do you configure pipeline triggers?
20. What is stash
and unstash
?
Temporary storage of files between stages or nodes.
21. How to handle build failures?
22. How do you implement input approval in pipeline?
23. How do you call other jobs from a pipeline?
24. How do you run pipeline on a specific node?
25. How do you check out multiple repositories?
26. How do you define global environment variables?
Via Jenkins UI under Manage Jenkins → Configure System or via environment
block in Jenkinsfile.
27. What is the difference between post
and steps
?
steps
define the main build commands; post
defines actions after the build like cleanup or notifications.
28. How do you run Groovy scripts in pipeline?
29. What is a Jenkins agent?
A machine that runs Jenkins jobs.
30. How do you pass variables between stages?
Use environment variables or store them in files and use stash
.
31. How do you secure Jenkins credentials?
Use Jenkins Credentials plugin and access via withCredentials
.
32. What is Blue Ocean?
A modern Jenkins UI for better visualization of pipelines.
33. How do you run tests and publish reports?
34. How do you integrate Docker with Jenkins?
Use Docker Pipeline plugin to build and push images.
35. How do you archive and fingerprint artifacts?
Expert (36–50)
36. How do you implement a multi-branch pipeline?
Use Multibranch Pipeline job type that auto-discovers branches with Jenkinsfiles.
37. How do you dynamically generate stages?
38. How do you trigger pipelines from external tools?
Use Jenkins REST API or plugins like Generic Webhook Trigger.
39. How do you secure Jenkins?
Use authentication, authorization, SSL, and least privilege principles.
40. How do you rollback deployments in Jenkins pipeline?
Implement rollback logic in pipeline steps or call rollback jobs.
41. How to implement parallelism with dynamic branches?
42. How do you manage pipeline libraries?
Create Shared Libraries stored in SCM, imported via @Library
annotation.
43. How do you upgrade Jenkins safely?
Backup configurations, plugins, and test upgrades in a staging environment.
44. How to handle Jenkins pipeline timeouts?
45. How do you monitor Jenkins jobs?
Use plugins like Monitoring, Email Extension, or external tools.
46. How do you implement conditional stages?
47. How do you create custom Jenkins plugins?
Develop Java plugins using Jenkins Plugin SDK and upload to Jenkins.
48. How to use Jenkins with Kubernetes?
Use Jenkins Kubernetes Plugin to dynamically provision agents in k8s clusters.
49. How do you pass parameters between Jenkins pipelines?
Use build
step with parameters and read them in downstream jobs.
50. How to handle secrets in Jenkins pipelines?
Use Jenkins Credentials Plugin and mask sensitive data in logs.
No comments:
Post a Comment