Skip to content

Instantly share code, notes, and snippets.

@docwhat
Created February 10, 2017 19:12
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save docwhat/645af0e13dd9be5403e453620e7e15fe to your computer and use it in GitHub Desktop.
Save docwhat/645af0e13dd9be5403e453620e7e15fe to your computer and use it in GitHub Desktop.
Jenkinsfile: check scm woes with the GitHub Org Folders
#!groovy
node {
stage('desired') {
// This is what I'd like to be able to do... Though there are lots of other extenions that are useful, like
// CleanBeforeCheckout and PruneStaleBranch
// Don't forget submodule configuration!
scm.extenions = scm.extensions + [[$class: 'CloneOption', noTags: true, reference: '', shallow: true]]
checkout scm
}
stage('alternate-desired') {
// Use a CPS library to build a _base_ duplicate SCM object. It would have userRemoteConfigs and branches
// already setup.
myScm = buildScm()
myScm.extensions = scm.extensions + [[$class: 'CloneOption', noTags: true, reference: '', shallow: true]]
checkout myScm
}
stage('what-i-have-to-do') {
// this is how I currently work around the problem.
checkout(
[
$class: 'GitSCM',
userRemoteConfigs: [[credentialsId: 'my-credentials-id', url: 'hard-coded-git-url-breaks-forking']],
branches: [[name: '*/$BRANCH_NAME']], // I don't like specifying the branch this way.
extensions: [
[$class: 'AuthorInChangelog'],
[$class: 'CheckoutOption', timeout: 10],
[$class: 'CleanBeforeCheckout'],
[$class: 'CloneOption', depth: 3, honorRefspec: true, noTags: true, reference: '', shallow: true, timeout: 3]
]
]
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment