Jenkins Pipeline Syntax: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 23: Line 23:


=Declarative Pipeline=
=Declarative Pipeline=
pipeline {
    agent any
    options {
        skipStagesAfterUnstable()
    }
    stages {
        stage('Build') {
            steps {
                sh 'make'
            }
        }
        stage('Test'){
            steps {
                sh 'make check'
                junit 'reports/**/*.xml'
            }
        }
        stage('Deploy') {
            steps {
                sh 'make publish'
            }
        }
    }
}


=Overview=
=Overview=

Revision as of 18:49, 25 October 2019

External

Internal


Scripted Pipeline

node {
    stage('Build') {
       // ...
    }
    stage('Test') {
       // ...
    }
    stage('Deploy') {
       // ...
    }

Declarative Pipeline

pipeline { 
    agent any 
    options {
        skipStagesAfterUnstable()
    }
    stages {
        stage('Build') { 
            steps { 
                sh 'make' 
            }
        }
        stage('Test'){
            steps {
                sh 'make check'
                junit 'reports/**/*.xml' 
            }
        }
        stage('Deploy') {
            steps {
                sh 'make publish'
            }
        }
    }
}

Overview

node {

    echo 'Pipeline logic starts'

}

Parallel Stages

stage("tests") {

    parallel(

        "unit tests": {

             // run unit tests 
         },
         "coverage tests": {

             // run coverage tests
         }
     )
}

Step Reference