Jenkins part 4: your first Jenkinsfile pipeline
Write a small Jenkinsfile with stages, keep it in source control, make a Pipeline job from it, and read the stage view to see which stage failed.
L1–L4 are part of the Pro pass
L0 Explain simply
Analogy: a bakery checklist on the wall. The list says mix, then bake, then check. The same helper can run it. A board by the door shows which step the current loaf is stuck on. Anyone can read the list. It is not hidden in the baker's head.
The list is the Jenkinsfile. The steps are stages. The board is the stage view.
Tom, a tester at Daily List, a to-do list app, writes the checklist into the project. Leo can review it like any other file.
What it is: A tells Jenkins, a (CI) server, what to do. It is a text file named Jenkinsfile in the project. A declarative stage block is a named part such as Test, and the stage view grid has one column per stage. A freestyle job is the neighbour, and that one is only a form on the website. This file can be reviewed in git.
Why it matters: A job that only exists in the Jenkins form cannot be reviewed in a . Tom can change a step without a written history. The Jenkinsfile puts the Daily List pipeline next to the tests, so Mei can read every stage before it runs.
PLAIN WORDS · 1 in this section
- declarative
- saying what should be true, not the steps
PICTURE IT
The picture is the one the lesson above opens with. The table below shows how each part of it matches the software.
THE REAL JOB A bakery line with a checklist on the wall.
- Checklist
- Jobs
- Board
HOW THE PICTURE MAPS
| In the picture | In the software |
|---|---|
| The checklist on the wall | The Jenkinsfile |
| One job on the list | A stage |
| Doing the job | A step |
| The board by the door | The stage view |
WHERE THIS PICTURE STOPS
- A checklist is on paper, but a Jenkinsfile is kept with the code.
- A baker may skip a job, but Jenkins runs the stages in order.
- A board shows loaves, but the stage view shows runs.
HOOK
Checklist, jobs, board.
TELL A FRIEND
A checklist, jobs and a board.
OFTEN MIXED UP WITH Jenkins part 3: triggers, schedules and parameters. That topic sets timers and choices on a job. This one writes the job as a file with stages and reads the stage view.
PRACTISE AND KEEP
Sources for this topic — 2 sources
- Market practice
Using a Jenkinsfile (Jenkins documentation) ↗ — Jenkins · Jenkins docs say a declarative pipeline is a series of stages. Each stage runs steps. The agent directive is required. The sh step runs a shell command on Unix-like systems. The post section supports conditions such as always
Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.
- Market practice
Getting started with Pipeline (Jenkins documentation) ↗ — Jenkins · Jenkins docs say you pick Pipeline script from SCM in a Pipeline job. You choose the source control type and repository. The Script Path field names the Jenkinsfile. Each stage becomes a column in the stage view
Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.
Deepest material on this page: L4 — Standards & sources. Where a topic stops short of implementation depth, that is a deliberate coverage decision, not an oversight — see coverage.