流水线支持两种语法:声明式(在 Pipeline 2.5 引入)和脚本式流水线。
声明式Jenkinsfile (Declarative Pipeline,声明式流水线)
pipeline {
agent {label 'openjdk8'}
stages {
stage('Hello') {
steps {
echo 'Hello World'
}
}
}
}
通过agent type来指定节点, Must be one of [any, kubernetes, label, none]
https://www.jenkins.io/zh/doc/book/pipeline/syntax/#agent-parameters
Jenkinsfile (Scripted Pipeline,脚本式流水线)
node ('openjdk8') {
stage('Hello') {
echo 'Hello World'
}
}
网友评论