Featured resource
2025 Tech Upskilling Playbook
Tech Upskilling Playbook

Build future-ready tech teams and hit key business milestones with seven proven plays from industry leaders.

Check it out
  • Lab
    • Libraries: If you want this lab, consider one of these libraries.
    • Cloud
Google Cloud Platform icon
Labs

Declarative Pipelines in Jenkins

In this hands-on lab we will be looking at Declarative Pipelines. Declarative style pipelines limit what is available to the user with a more strict and pre-defined structure, making it an ideal choice for simpler continuous delivery pipelines. We'll be building the Pipeline (Declarative) and ensuring that it has gone through the build stages as defined and provided a satisfactory Jenkins job result.

Google Cloud Platform icon
Lab platform
Lab Info
Level
Intermediate
Last updated
Sep 22, 2025
Duration
30m

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.
Table of Contents
  1. Challenge

    Jenkins UI

    Once you access the Jenkins landing page, click New Item on the left side of the screen to proceed towards selecting the type of Jenkins job you want to create.

    Once the new page loads, click on Pipeline and in the input box give a name to your job, such as MyDeclarativePipeline.

    After selecting the type of job, Pipeline, and giving it a name, click on OK to proceed with configuring the job.

  2. Challenge

    Configuring a Jenkins Pipeline Job (Declarative Pipeline)

    On the new page which loads for configuring the pipeline job, scroll down to the Pipeline section and ensure that Pipeline Script is selected in the Definition drop-down. An input area should be visible. Copy the following body of text (which is basically in Groovy DSL format, a format understood by Jenkins) into the input area:

    pipeline {
        agent {
            docker { image 'linuxacademycontent/jenkins_pipelines' }
        }
        stages {
            stage('fetch') {
                steps {
                    sh 'git clone https://github.com/linuxacademy/content-pipelines-cje-labs.git'
                }
            }
            stage('build'){
                steps{
                    sh 'gcc --std=c99 -o mario content-pipelines-cje-labs/lab1_lab2/mario.c'
                }
            }
            stage('archive'){
                steps{
                    archiveArtifacts artifacts: 'mario'
                }
            }
        }
    }
    

    Leave everything else at the default settings and click on Save.

    Note: This Declarative Pipeline will pull down and run a Docker container which has git and gcc utilities installed for cloning and compiling the code.

  3. Challenge

    Running/Building Your Jenkins Declarative Pipeline Job

    After hitting Save in the previous step, you will be taken to the control page for the job you just configured. There you can see the job status and other job statistics, and you will be able to edit the configuration again.

    To kick off a build, click on Build Now. This should start the build, and you should see the output of build status in a couple of places on your current screen.

    Under the Build History box, on the left of your screen you'll see a build number, and a progress bar if the build is currently running. The page will also be updated with a Stage View, which gives details of execution success (green) and the time taken by each build stage that was defined in our Declarative Pipeline. Subsequent builds will add more data to average run times in the same area.

    If you click on the build number under Build History (#1 for example), you will be taken to the details of the specific build. This includes things like Console Output for showing the execution of commands defined in the pipeline for each step.

    On this page you'll also find the build output files, or Build Artifacts, which are the outcome of the pipeline stages that you built. You can click on the actual file name shown under build artifacts to download it to your system.

About the author

Pluralsight Skills gives leaders confidence they have the skills needed to execute technology strategy. Technology teams can benchmark expertise across roles, speed up release cycles and build reliable, secure products. By leveraging our expert content, skill assessments and one-of-a-kind analytics, keep up with the pace of change, put the right people on the right projects and boost productivity. It's the most effective path to developing tech skills at scale.

Real skill practice before real-world application

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Learn by doing

Engage hands-on with the tools and technologies you’re learning. You pick the skill, we provide the credentials and environment.

Follow your guide

All labs have detailed instructions and objectives, guiding you through the learning process and ensuring you understand every step.

Turn time into mastery

On average, you retain 75% more of your learning if you take time to practice. Hands-on labs set you up for success to make those skills stick.

Get started with Pluralsight