How do I achieve git Additional Behaviors => Checkout to specific local branch in Jenkins pipeline?

Viewed 5719

How do we achieve Git Additional Behavior in Jenkins pipeline?

Additional Behaviors
=> checkout to specific local branch

2 Answers

check this one http://your-Jenkins:8080/pipeline-syntax/ , you can have samples of all your installed plugins.

checkout([$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'your-sub-directory']], gitTool: 'Default', submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'd767bb7a-4c1e-4654-a310-996d4ece5b02', url: 'git@github.com:yyy/xxx.git']]])

enter image description here

you can find the pipeline syntax in your Jenkins job slide bar Pipeline Syntax section.

enter image description here

1、Sample Step select checkout: Check out from version control

2、click Additional Behaviours Add button

3、select checkout to specific local branch

4、click bottom Generate Pipeline Script button,you will get pipeline script.

Related