Ravindra BagaleCourses & study guides मराठी

Ravi Sir's Cards › DevOps

Chapter 21: Jenkins Pipeline and Jenkinsfile: Cards

मराठी cards · Open the chapter

Revision cards

Why move a freestyle job into a Jenkinsfile. UI settings are lost if the server dies, and nobody sees who changed them.
Revision card 1 of 16: Why move a freestyle job into a Jenkinsfile · Download PNG · Open card page

Lesson: 21.1 Why move Freestyle into a Jenkinsfile

Declarative vs Scripted pipeline. Teams need pipelines that new people can read and review fast.
Revision card 2 of 16: Declarative vs Scripted pipeline · Download PNG · Open card page

Lesson: 21.2 Declarative vs Scripted (pick Declarative)

Create a Pipeline job from SCM. If the pipeline is typed into the job page, it is not in Git and not reviewed.
Revision card 3 of 16: Create a Pipeline job from SCM · Download PNG · Open card page

Lesson: 21.3 Create a Pipeline job from SCM

badge-node project shape. The pipeline only works if the repo has the files its stages expect.
Revision card 4 of 16: badge-node project shape · Download PNG · Open card page

Lesson: 21.4 Same Node.js app — project shape reminder

CI/CD pipeline stages: lint, test, build, push, deploy. Manual releases forget steps. A pipeline runs the same checks in the same order on every code push.
Revision card 5 of 16: CI/CD pipeline stages: lint, test, build, push, deploy · Download PNG · Open card page

Lesson: 21.5 Full Declarative Jenkinsfile for badge Node

Bind a credential by ID. Secrets must reach the build without being written in the Jenkinsfile.
Revision card 6 of 16: Bind a credential by ID · Download PNG · Open card page

Lesson: 21.6 Optional: bind a credential by id (pattern only)

agent and tools: Node must exist. If the agent has no Node, npm fails before any test runs.
Revision card 7 of 16: agent and tools: Node must exist · Download PNG · Open card page

Lesson: 21.7 Agent tools: Node must exist

Multibranch pipeline: awareness. Teams have many branches. Making a job by hand for each is slow.
Revision card 8 of 16: Multibranch pipeline: awareness · Download PNG · Open card page

Lesson: 21.8 Multibranch awareness (not required for the lab)

Same badge build, two shapes. Interviewers ask how a click job maps to code.
Revision card 9 of 16: Same badge build, two shapes · Download PNG · Open card page

Lesson: 21.9 Freestyle vs Pipeline — same badge, two shapes

Pipeline troubleshooting. A pipeline can fail before any code runs, from a syntax or setup problem.
Revision card 10 of 16: Pipeline troubleshooting · Download PNG · Open card page

Lesson: 21.10 Troubleshooting

Declarative blocks you must read. In interviews and on the job, you must read any Jenkinsfile quickly.
Revision card 11 of 16: Declarative blocks you must read · Download PNG · Open card page

Lesson: 21.11 Declarative blocks you must be able to read

options: timeout, retry, timestamps. A stuck build can hold an executor for hours and block others.
Revision card 12 of 16: options: timeout, retry, timestamps · Download PNG · Open card page

Lesson: 21.12 Options: timeout, retry, timestamps, one build at a time

stash, input approval and currentBuild. Some steps run on other machines, and production needs a human yes.
Revision card 13 of 16: stash, input approval and currentBuild · Download PNG · Open card page

Lesson: 21.13 Stash, approval, and currentBuild

parameters, when, parallel and matrix. Pipelines need choices and speed without copying stages.
Revision card 14 of 16: parameters, when, parallel and matrix · Download PNG · Open card page

Lesson: 21.14 Parameters, when, parallel, and matrix

Scripted pipeline and a little Groovy. Some old pipelines are Scripted, and some logic needs a loop.
Revision card 15 of 16: Scripted pipeline and a little Groovy · Download PNG · Open card page

Lesson: 21.15 Scripted Pipeline and a little Groovy

Triggers written in the Jenkinsfile. Triggers set in the UI are not reviewed and can be lost.
Revision card 16 of 16: Triggers written in the Jenkinsfile · Download PNG · Open card page

Lesson: 21.16 Triggers written in the Jenkinsfile

Interview cards

Why keep the pipeline in a Jenkinsfile? A Jenkinsfile lives in Git, so changes are reviewed, versioned and easy to restore or copy.
Interview card 1 of 16: Why keep the pipeline in a Jenkinsfile? · Download PNG · Open card page

Lesson: 21.1 Why move Freestyle into a Jenkinsfile

Declarative or Scripted pipeline? Declarative: fixed blocks, easy to read, checks syntax early. Scripted: free Groovy, more power, harder to read.
Interview card 2 of 16: Declarative or Scripted pipeline? · Download PNG · Open card page

Lesson: 21.2 Declarative vs Scripted (pick Declarative)

How does a Pipeline job find the Jenkinsfile? Set Definition to Pipeline script from SCM, give repo, branch, credential ID, and Script Path (default Jenkinsfile).
Interview card 3 of 16: How does a Pipeline job find the Jenkinsfile? · Download PNG · Open card page

Lesson: 21.3 Create a Pipeline job from SCM

Why change the Jenkinsfile and code in one pull request? So the pipeline always matches the code. A new test command and its stage arrive together.
Interview card 4 of 16: Why change the Jenkinsfile and code in one pull request? · Download PNG · Open card page

Lesson: 21.4 Same Node.js app — project shape reminder

Which stages should a CI/CD pipeline have? Common order: checkout → lint → test → build → push → deploy. Each stage stops the pipeline if it fails.
Interview card 5 of 16: Which stages should a CI/CD pipeline have? · Download PNG · Open card page

Lesson: 21.5 Full Declarative Jenkinsfile for badge Node

How do you use a secret in a Jenkinsfile? Use withCredentials with the credential ID. The secret is an environment variable only inside the block and masked in logs.
Interview card 6 of 16: How do you use a secret in a Jenkinsfile? · Download PNG · Open card page

Lesson: 21.6 Optional: bind a credential by id (pattern only)

What does the tools block do? It adds a tool, like Node or Maven, by the name set in Manage Jenkins → Tools, to the PATH for the build.
Interview card 7 of 16: What does the tools block do? · Download PNG · Open card page

Lesson: 21.7 Agent tools: Node must exist

What is a Multibranch Pipeline? A job that scans a repo and makes one pipeline per branch or pull request that has a Jenkinsfile.
Interview card 8 of 16: What is a Multibranch Pipeline? · Download PNG · Open card page

Lesson: 21.8 Multibranch awareness (not required for the lab)

How does a freestyle job map to a Jenkinsfile? SCM → checkout scm, shell step → sh, post-build archive → post { success { archiveArtifacts } }.
Interview card 9 of 16: How does a freestyle job map to a Jenkinsfile? · Download PNG · Open card page

Lesson: 21.9 Freestyle vs Pipeline — same badge, two shapes

“No such DSL method” error. What does it mean? The step name is not known. Usually a typo or a missing plugin that adds that step.
Interview card 10 of 16: “No such DSL method” error. What does it mean? · Download PNG · Open card page

Lesson: 21.10 Troubleshooting

Name the main blocks of a Declarative pipeline. pipeline, agent, stages with stage and steps, and post. Optional: environment, options, parameters, when.
Interview card 11 of 16: Name the main blocks of a Declarative pipeline. · Download PNG · Open card page

Lesson: 21.11 Declarative blocks you must be able to read

How do you stop a stuck Jenkins build? Add options { timeout(...) }. Jenkins aborts the build when time runs out.
Interview card 12 of 16: How do you stop a stuck Jenkins build? · Download PNG · Open card page

Lesson: 21.12 Options: timeout, retry, timestamps, one build at a time

How do you add a manual approval in a pipeline? Use the input step. The build pauses until an allowed user clicks Proceed.
Interview card 13 of 16: How do you add a manual approval in a pipeline? · Download PNG · Open card page

Lesson: 21.13 Stash, approval, and currentBuild

How do you run deploy only on the main branch? Use when { branch 'main' } on the deploy stage. Other branches skip it.
Interview card 14 of 16: How do you run deploy only on the main branch? · Download PNG · Open card page

Lesson: 21.14 Parameters, when, parallel, and matrix

When do you use a script block? When Declarative cannot express it, like a loop. script { } runs Groovy inside a stage.
Interview card 15 of 16: When do you use a script block? · Download PNG · Open card page

Lesson: 21.15 Scripted Pipeline and a little Groovy

How do you set a nightly build in a Jenkinsfile? Add triggers { cron('H 2 * * *') }. H spreads the start time to avoid load spikes.
Interview card 16 of 16: How do you set a nightly build in a Jenkinsfile? · Download PNG · Open card page

Lesson: 21.16 Triggers written in the Jenkinsfile

Comparison cards

Declarative vs Scripted pipeline. Two ways to write a Jenkinsfile.Declarative: fixed blocks inside pipeline { }.Scripted: Groovy code inside node { }.
Comparison card 1 of 3: Declarative vs Scripted pipeline · Download PNG · Open card page

Lesson: 21.2 Declarative vs Scripted (pick Declarative)

Freestyle job vs Pipeline job. Freestyle: job set up by web forms.Pipeline: job read from a Jenkinsfile.
Comparison card 2 of 3: Freestyle job vs Pipeline job · Download PNG · Open card page

Lesson: 21.9 Freestyle vs Pipeline — same badge, two shapes

stash vs archiveArtifacts. Both save files from a build.stash: keeps files for a later stage of the same run.archiveArtifacts: keeps files with the build.
Comparison card 3 of 3: stash vs archiveArtifacts · Download PNG · Open card page

Lesson: 21.13 Stash, approval, and currentBuild