Created
February 10, 2017 19:12
-
-
Save docwhat/645af0e13dd9be5403e453620e7e15fe to your computer and use it in GitHub Desktop.
Jenkinsfile: check scm woes with the GitHub Org Folders
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!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