Jenkins¶
25 cards β π’ 2 easy | π‘ 5 medium | π΄ 3 hard
π’ Easy (2)¶
1. What are Credentials in Jenkins, and what types are supported?
Show answer
* Credentials: Stored authentication information used by Jenkins jobs.* Supported types: Jenkins supports various credential types like Username/Password, Secret text, SSH private key, Certificate, Username/Password (Amazon Web Services), and more.
Gotcha: never hardcode secrets in Jenkinsfiles. Use withCredentials block. Credentials are masked in logs by default.
2. What is the difference between Continous Integration and Continour Delivery ?
Show answer
* Continuous Delivery: It's the practice of ensuring software can be released to production at any time but not necessarily automatically deployed. It focuses on automated testing, deployment-ready code, and enabling frequent releases.* Continuous Deployment: It extends continuous delivery by automatically deploying each successful build to production without human intervention, assuming all quality checks pass.
π‘ Medium (5)¶
1. How to trigger job outside of Jenkins.
Show answer
Jobs can be triggered outside Jenkins via Jenkins Remote Access API, allowing you to trigger builds remotely using tools or scripts. Alternatively, Jenkins provides webhooks or integrations with version control systems, chat platforms like Slack, or other CI/CD tools that can trigger jobs externally.Example: curl -X POST http://jenkins/job/myjob/build --user user:token triggers remotely. Webhooks trigger on push.
2. How to pass a variableβs/parameter value to another parameter?
Show answer
Use Jenkins parameters to pass information from one job to another. Parameters can be defined as build parameters or environment variables, allowing data exchange between jobs. Use the Parameterized Trigger plugin or pass values via env vars in pipeline steps.Example: build job: 'downstream', parameters: [string(name: 'VERSION', value: env.BUILD_TAG)]
3. Explain the Jenkins shared library and its purpose.
Show answer
Jenkins Shared Library: A collection of reusable pipeline code. It enables sharing common code, functions, and procedures across multiple pipelines, improving maintainability and readability.Example: vars/deployToK8s.groovy in a Git repo. Pipelines: @Library('mylib'). Eliminates copy-paste across Jenkinsfiles.
4. Why can we delete freestyle jobs but not Pipeline jobs ?
Show answer
`Freestyle jobs` can be deleted in the background because they donβt involve complex interdependencies and are standalone,whereas `Pipeline jobs`, defined in Jenkinsfile, have interdependencies and are handled differently, ensuring no accidental deletion due to their code-based nature and possible complexities.
Under the hood: Pipeline = code (Jenkinsfile), riskier to delete. Freestyle = UI-configured, standalone lifecycle.
5. Where is all user data stored on the server ?
Show answer
Jenkins user data is usually stored in the JENKINS_HOME directory. The specific location varies based on the installation and operating system but typically contains configuration, job data, logs, and plugins.Remember: JENKINS_HOME (/var/lib/jenkins/) = config + jobs + plugins + secrets. Back it up β losing it = losing Jenkins.
π΄ Hard (3)¶
1. Difference between Parallel and Sequential Jobs.
Show answer
* Sequential Execution: Jobs executed one after another in a sequence.* Parallel Execution: Jobs executed concurrently, allowing multiple tasks to run simultaneously. Use sequential for dependent tasks and parallel for independent tasks or to speed up the overall build time by leveraging available resources efficiently.
2. Tell me the difference between an executor and an agent.
Show answer
* Agent: A machine (physical or virtual) that executes Jenkins builds. It can have multiple executors.* Executor: Represents a single task within a Jenkins agent. An agent can have multiple executors, which run individual jobs or build steps.
Remember: Agent=machine, Executor=build slot. 4 executors on 1 agent = 4 concurrent builds.
3. Explain the difference between a Jenkins executor and a Jenkins worker node.
Show answer
* Executor: Represents a task within a worker node. A worker node can have multiple executors running in parallel.* Worker Node: The physical or virtual machine where builds are executed, it can run multiple executors and handle several concurrent tasks.