1. 安装pipline 插件(一般情况,pipline 是已安装的)

  2. 参数化配置中选择 Git Parameter    

    name: branch
    Parameter type:Branch

3. 配置Pipeline

Pipeline 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