Pipeline as Code
- This approach is defining steps required for building CI/CD expressed as a code in version control system.
- Advantages:
- Changes done in pipeline over a period of time will have history in git.
- Per branch i can different build steps
- It also allows to create reusability
- Jenkins started doing Pipeline as code with Scripted Pipelines and then they have also provided Declarative Pipelines
-
Scripted Pipeline:
- This is the Pipeline expressed in groovy language.
- These pipelines are very much useful if your CI/CD pipeline has complex steps.
-
Declartive Pipeline:
- This pipeline is expressed in the form of Jenkins DSL (Domain Specific Language) which internally uses groovy.
- This has been implemented to reduce the learning curve.
-
The Pipeline as Code in Jenkins can be expressed in any file but file with name
Jenkinsfileis commonly used.
- Refer Here for official docs
Declartive Pipelines in Jenkins
- Syntax Refer Here

- Agent Section: Refer Here
- environment Refer Here
- options section: Refer Here
- triggers Refer Here
- parameters Refer Here
- tools Refer Here
- libraries: to be discussed later
- stages: Each stage should be a stage in your CI/CD Pipeline Refer Here
- stage: Refer Here
- steps: Refer Here
- steps reference Refer Here
- Git Step Refer Here
Spring pet clinic day build in Declarative Pipleine
- Refer Here for the pipeline.
- Now lets create a Jenkins Pipeline Project



- Now lets trigger a manual build

- Refer Here for the steps added to publish test results and archive the artifacts

