Jenkins Pipeline Syntax: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
No edit summary
Line 11: Line 11:
=Scripted Pipeline=
=Scripted Pipeline=


<syntaxhighlight lang='groovy'>
  node {
  node {
   
   
Line 24: Line 25:
         // ...
         // ...
     }
     }
</syntaxhighlight>


==Parallel Stages==
==Parallel Stages==
Line 48: Line 50:
=Declarative Pipeline=
=Declarative Pipeline=


<syntaxhighlight lang='groovy'>
  pipeline {  
  pipeline {  
     agent any  
     agent any  
Line 72: Line 75:
     }
     }
  }
  }
 
</syntaxhighlight>
=Step Reference=
=Step Reference=


* [https://jenkins.io/doc/pipeline/steps/workflow-basic-steps/#stash-stash-some-files-to-be-used-later-in-the-build stash]
* [https://jenkins.io/doc/pipeline/steps/workflow-basic-steps/#stash-stash-some-files-to-be-used-later-in-the-build stash]

Revision as of 19:32, 25 October 2019

External

Internal


Scripted Pipeline

 node {
 
     echo 'Pipeline logic starts'
 
     stage('Build') {
        // ...
     }
     stage('Test') {
        // ...
     }
     stage('Deploy') {
        // ...
     }

Parallel Stages

stage("tests") {

    parallel(

        "unit tests": {

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

             // run coverage tests
         }
     )
}

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'
             }
         }
     }
 }

Step Reference