Jenkins Pipeline Syntax: Difference between revisions
Jump to navigation
Jump to search
Line 78: | Line 78: | ||
=Pipeline Steps= | =Pipeline Steps= | ||
{{External|https://jenkins.io/doc/pipeline/steps/}} | {{External|https://jenkins.io/doc/pipeline/steps/}} | ||
====node==== | |||
{{External|https://jenkins.io/doc/pipeline/steps/workflow-durable-task-step/#-node-allocate-node} | |||
Allocate node. | |||
====sh==== | |||
{{External|https://jenkins.io/doc/pipeline/steps/workflow-durable-task-step/#-sh-shell-script}} | |||
Shell Script. | |||
====ws==== | |||
{{External|https://jenkins.io/doc/pipeline/steps/workflow-durable-task-step/#-ws-allocate-workspace}} | |||
Allocate workspace. | |||
==Basic Steps Reference== | ==Basic Steps Reference== |
Revision as of 17:42, 21 November 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'
}
}
}
}
Pipeline Steps
node
{{External|https://jenkins.io/doc/pipeline/steps/workflow-durable-task-step/#-node-allocate-node}
Allocate node.
sh
Shell Script.
ws
Allocate workspace.
Basic Steps Reference
These basic steps are used invoking on stage.
. In a Jenkinsfile, and inside a stage, invoke on this.
or simply invoking directly, without qualifying.
echo
error
readFile
Read a file from the workspace.
def versionFile = readFile("${stage.WORKSPACE}/terraform/my-module/VERSION")