0 votes
in Jenkins by
What are Declarative Pipelines in Jenkins?

1 Answer

0 votes
by
Declarative Pipelines are the newest additions to Jenkins that simplify the groovy syntax of Jenkins pipelines (top-level pipeline) with some exceptions, such as:

No semicolon to be used as a statement separator. The top-level pipeline should be enclosed within block viz;

The common syntax is:

pipeline {

/* Declarative Pipeline */

}

Blocks must contain Sections, Directives, steps or assignments.

pipeline {

                agent any

                stages {

stage(‘Build’) {

                steps {

// Statements…

                }

                }

       stage (‘Test’) {

       steps {

              // Statements…

       }

       }

    }

}

The above code has 3 major elements

Pipeline: The block of script contents.

Agent: Defines where the pipeline will start running from.

Stage: The pipelines contain several steps enclosed in the block called Stage.

Related questions

0 votes
asked Nov 16, 2022 in Jenkins by Robin
0 votes
asked May 1, 2021 in Jenkins by rajeshsharma
...