Skip to content

Instantly share code, notes, and snippets.

@scottnixonjr
Created November 30, 2020 20:48
Show Gist options
  • Save scottnixonjr/24016cea4945226b82302dc89743c75a to your computer and use it in GitHub Desktop.
Save scottnixonjr/24016cea4945226b82302dc89743c75a to your computer and use it in GitHub Desktop.

Git Checkout in Jenkins

By default, the Jenkins checkout plugin wipes the directory before checkout. This configuration allows you to checkout to a seperate directory. SSH authentication to github.

checkout([
        $class: 'GitSCM', 
        branches: [[name: '*/master']],
        extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'any-directory-name']],
        userRemoteConfigs: [[credentialsId: env.SSH_CRED_ID, url: 'git@github.com:snixon/myrepo-is-awesome.git']]
    ])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment