# Day 26 Task: Jenkins Declarative Pipeline

**Introduction:** In the realm of DevOps and CI/CD, the Jenkins Declarative Pipeline stands as a pivotal element, offering a structured and code-driven approach to defining, managing, and automating the software delivery process. This task delves into the foundational steps of creating a Jenkins Declarative Pipeline job, emphasizing the significance of treating the CI/CD pipeline as code.

Task-01: Creating a Jenkins Declarative Pipeline Job

**Step 1: Open Jenkins Dashboard and Create a New Pipeline Job**

* Access your Jenkins dashboard and click on "New Item."
    
* Enter a name for your job (e.g., "MyDeclarativePipelineJob").
    
* Choose "Pipeline" as the job type and click on "OK."
    

**Step 2: Configure Pipeline Script**

* In the job configuration page, find the "Pipeline" section.
    
* Select "Pipeline script" from the Definition dropdown.
    

**Step 3: Write a Declarative Pipeline Script**

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1701952732491/36a75468-40d0-4a5e-82b0-0ad715f2b7a1.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1701952845711/6b9e8ed8-a3e6-430f-8bd9-3a3fb809af75.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1701952876903/d2d7b4e7-cdd9-49de-80b5-aad2ee36a5bd.png align="center")

Replace the script with a more comprehensive example:

This script includes various features such as environment variables, pipeline options, manual input parameters, and conditional stages. Customize it according to your project's requirements.

**Step 4: Save and Run the Pipeline**

Scroll down and click on "Save" to save the pipeline configuration.

Click on "Build Now" to run the pipeline.

**Step 5: View Results**

Monitor the progress and view the console output by clicking on the build number in the "Build History" section.

This extended example provides a more comprehensive template for a Declarative Pipeline, allowing you to incorporate advanced features and customization into your CI/CD process. Don't forget to commit your Jenkinsfile to version control for better traceability and collaboration.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1701953027764/593c85a5-0d11-446d-b352-62b3aeb52f78.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1701953049009/957469fc-ec5d-472f-8ca2-59c2d182a58e.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1701953184763/d9f039bb-7c1d-4c88-9602-78cf2b6a3af3.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1701953220946/c43edac6-855b-48e3-91ad-4a6b6e479ef0.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1701953281442/6cb8c08a-3f87-4bb8-be0a-679df931ab5f.png align="center")

**Conclusion:** This task underscores the essence of Jenkins Declarative Pipelines in modern CI/CD practices. By embracing a code-centric approach, teams can achieve versioning, traceability, and collaboration for their CI/CD pipelines, marking a significant stride towards efficient and reproducible software delivery.
