安装pipline 插件(一般情况,pipline 是已安装的)
参数化配置中选择 Git Parametername: branch
Parameter type:Branch
3. 配置PipelinePipeline script #在jenkins 页面配置脚本
Pipeline script from SCM #在脚本服务器中配置脚本,通过git 获取配置脚本信息
4.测试脚本node('web') { //此处配置slave node
// def mvnHome
stage('checkout') { // for display purposes
checkout([$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[url: 'git@10.10.95.2:/home/git/repos/app.git']]])
}
stage('maven build') {
echo 'maven build ....'
echo 'maven build .....'
echo 'maven build .....'
}
stage('deploy') {
echo 'deploy .....'
echo 'deploy .....'
echo 'deploy ......'
}
stage('test') {
echo 'test ......'
echo 'test ........'
echo 'test .......'
}
}
5. 测试服务器中获取脚本在脚本服务器中配置脚本信息,提交到git 服务器,Jenkins 从git服务器中获取脚本,更新代码
例如:
git add .
git commit -m ""
git push origin master