failed: This step will execute only when the current build of our pipeline has failed.

changed: This step will execute only when the current state of our pipeline is different from the previous state.

To discover all the steps in the post module, you can refer to the Jenkins documentation here.

7. triggers:This is used when we want to specify after how much time our pipeline will be triggered. It has parameters like

cron: It takes a cron type expression to see after how much time a pipeline should trigger itself. To learn more about cron expressions, see here.

This will automatically trigger my pipeline every five minutes.

poll SCM: This defines a regular interval after which Jenkins will poll our git environment to see whether there is a change in our source code. If yes, then it will trigger our build.

This pipeline will tell Jenkins to continuously poll our GitHub every five minutes to see if there is a change in our source code. If yes then it will start to execute stages in our pipeline.

8. when: To run a particular stage on the given condition, we use the whenblock.

The compile stage will only run when the branch on GitHub is the master. If it is a branch other than the master, it will skip this step. To learn more about the whenclause and what parameters it takes, click here.

9. sequential stages: AJenkins pipeline can become quite complex sometimes. We can declare stages inside stages; this structure of writing pipelines is known as sequential stages. Nested stages will run in a sequential order.

10. parallel stage:We can even run our stages in parallel on different machines. Just add a parallel {} block in our stages and our stages will run in parallel on different agents.

I hope this blog was helpful in understanding the basic structure of a Jenkins Declarative Pipeline. If you want to explore more about Jenkins pipelines, you can refer to the Jenkins documentation here.