pipeline片段(对应jenkins-cli -p参数的BRANCH=develop)
parameters { string ( name: 'BRANCH' , defaultValue : 'master' , description : 'Enter the branch name' ) } stages { stage ( 'Get Code' ) { steps { script { def branch = params. BRANCH checkout scmGit ( branches: [ [ name: '*/${branch}' ] ] , extensions : [ ] , userRemoteConfigs : [ [ credentialsId: 'git' , url : 'http://gitlab.123.com/official-website.git' ] ] ) } } }
使用 build -p参数 BRANCH=develop (develops是你的分支名),或者下面对应即可
运行
java -jar jenkins-cli.jar -s http : //127.0.0.1 -auth 用户 : 密码 build 你的job -p BRANCH=你的分支名 -v -s -f
java -jar jenkins-cli.jar -s http : //192.168.0.133: 32003 -auth admins : 123qwe build demon/asdsd -p BRANCH=develop -v -s -f