1. 流水线指定节点运行
agent{
label 'linuxNogui3'
}
2. pipeline中进行参数化构建
参数化构建可分为布尔值参数、选项参数、凭据参数、文件参数、密码参数、运行时参数、字符参数、文本参数,定义及其使用方式如下:
pipeline {
agent any
parameters {
#字符参数
string(name: 'PERSON', defaultValue: 'Mr Jenkins', description: 'Who should I say hello to?')
#文本参数
text(name: 'BIOGRAPHY', defaultValue: '', description: 'Enter some information about the person')
#布尔值参数
booleanParam(name: 'TOGGLE', defaultValue: true, description: 'Toggle this value')
#选项参数
choice(name: 'CHOICE', choices: ['One', 'Two', 'Three'], description: 'Pick something')
#密码参数
password(name: 'PASSWORD', defaultValue: 'SECRET', description: 'Enter a password')
}
stages {
stage('Example') {
steps {
echo "Hello ${params.PERSON}"
echo "Biography: ${params.BIOGRAPHY}"
echo "Toggle: ${params.TOGGLE}"
echo "Choice: ${params.CHOICE}"
echo "Password: ${params.PASSWORD}"
}
}
}
}
3. pipeline触发器
触发器类型主要分为:定时构建、githubPush(用于github的hook触发)、gitlab(用于gitlab的webhook触发)、poolSCM、upstream(其他工程构建后触发)
(1)gitlab