I am getting started with Jenkins declarative Pipeline. From some of the examples I have seen, I notice that the Jenkinsfile is setup with the Pipeline directive:
pipeline {
agent any
stages {
stage('Build') {
steps {
sh 'make'
}
}
stage('Test'){
steps {
sh 'make check'
junit 'reports/**/*.xml'
}
}
stage('Deploy') {
steps {
sh 'make publish'
}
}
}
}
In other examples, I notice that the Jenkinsfile is setup with a node directive:
node {
stage 'Checkout'
checkout scm
stage 'Build'
bat 'nuget restore SolutionName.sln'
bat "\"${tool 'MSBuild'}\" SolutionName.sln /p:Configuration=Release /p:Platform=\"Any CPU\" /p:ProductVersion=1.0.0.${env.BUILD_NUMBER}"
stage 'Archive'
archive 'ProjectName/bin/Release/**'
}
I haven't been able to find solid documentation on exactly when / why to use each of these. Does anybody have any information on why these differ and when it is appropriate to use either of them?
I'm not sure but I belive the 'node' directive is used in scripted pipeline as opposed to declarative pipeline.
Thanks in advance for any guidance.