@@ -663,33 +663,35 @@ class BitbucketScm extends Scm {
663663 * Checkout the source code from a repository; resolves as an object with checkout commands
664664 * @method getCheckoutCommand
665665 * @param {Object } config
666- * @param {String } config.branch Pipeline branch
667- * @param {String } config.host Scm host to checkout source code from
668- * @param {String } config.org Scm org name
669- * @param {String } config.repo Scm repo name
670- * @param {String } config.sha Commit sha
671- * @param {String } [config.prRef] PR reference (can be a PR branch or reference)
666+ * @param {String } config.branch Pipeline branch
667+ * @param {String } config.host Scm host to checkout source code from
668+ * @param {String } config.org Scm org name
669+ * @param {String } config.repo Scm repo name
670+ * @param {String } config.sha Commit sha
671+ * @param {String } [config.commitBranch] Commit branch
672+ * @param {String } [config.prRef] PR reference (can be a PR branch or reference)
672673 * @return {Promise }
673674 */
674675 _getCheckoutCommand ( config ) {
675676 const checkoutUrl = `${ config . host } /${ config . org } /${ config . repo } ` ;
676677 const sshCheckoutUrl = `git@${ config . host } :${ config . org } /${ config . repo } ` ;
677- const checkoutRef = config . prRef ? config . branch : config . sha ;
678+ const branch = config . commitBranch ? config . commitBranch : config . branch ;
679+ const checkoutRef = config . prRef ? branch : config . sha ;
678680 const gitWrapper = '$(if git --version > /dev/null 2>&1; ' +
679681 "then echo 'eval'; " +
680682 "else echo 'sd-step exec core/git'; fi)" ;
681683 const command = [ ] ;
682684
683685 // Git clone
684- command . push ( `echo Cloning ${ checkoutUrl } , on branch ${ config . branch } ` ) ;
686+ command . push ( `echo Cloning ${ checkoutUrl } , on branch ${ branch } ` ) ;
685687 command . push ( 'if [ ! -z $SCM_CLONE_TYPE ] && [ $SCM_CLONE_TYPE = ssh ]; ' +
686688 `then export SCM_URL=${ sshCheckoutUrl } ; ` +
687689 'elif [ ! -z $SCM_USERNAME ] && [ ! -z $SCM_ACCESS_TOKEN ]; ' +
688690 `then export SCM_URL=https://$SCM_USERNAME:$SCM_ACCESS_TOKEN@${ checkoutUrl } ; ` +
689691 `else export SCM_URL=https://${ checkoutUrl } ; fi`
690692 ) ;
691693 command . push ( `${ gitWrapper } `
692- + `"git clone --quiet --progress --branch ${ config . branch } $SCM_URL $SD_SOURCE_DIR"` ) ;
694+ + `"git clone --quiet --progress --branch ${ branch } $SCM_URL $SD_SOURCE_DIR"` ) ;
693695 // Reset to Sha
694696 command . push ( `echo Reset to SHA ${ checkoutRef } ` ) ;
695697 command . push ( `${ gitWrapper } "git reset --hard ${ checkoutRef } "` ) ;
@@ -702,7 +704,7 @@ class BitbucketScm extends Scm {
702704 if ( config . prRef ) {
703705 const prRef = config . prRef . replace ( 'merge' , 'head:pr' ) ;
704706
705- command . push ( `echo Fetching PR and merging with ${ config . branch } ` ) ;
707+ command . push ( `echo Fetching PR and merging with ${ branch } ` ) ;
706708 command . push ( `${ gitWrapper } "git fetch origin ${ prRef } "` ) ;
707709 command . push ( `${ gitWrapper } "git merge --no-edit ${ config . sha } "` ) ;
708710 }
0 commit comments