Skip to content

Instantly share code, notes, and snippets.

@BillyPurvis
Last active January 14, 2024 18:40
Show Gist options
  • Save BillyPurvis/67093ded71bfcb35ff2a42e9a9f36196 to your computer and use it in GitHub Desktop.
Save BillyPurvis/67093ded71bfcb35ff2a42e9a9f36196 to your computer and use it in GitHub Desktop.
A Basic Jenkins Scripted Pipeline Github Clone Repo Stage
String branchName = env.BRANCH_NAME
String gitCredentials = "CREDENTIAL_ID"
String repoUrl = "https://github.com/username/repo-name.git"
node {
// Start Stages
stage('Clone') {
// Clones the repository from the current branch name
echo 'Make the output directory'
sh 'mkdir -p build'
echo 'Cloning files from (branch: "' + branchName + '" )'
dir('build') {
git branch: branchName, credentialsId: gitCredentials, url: repoUrl
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment