gitlab-plugin icon indicating copy to clipboard operation
gitlab-plugin copied to clipboard

Checkout step doesn't respect the parameters

Open forry opened this issue 3 years ago • 1 comments

Version report

Jenkins and plugins versions report:

Jenkins 2.277.2
GitLab Plugin 1.5.20
Git Plugin 4.7.1
Git client plugin 3.7.1
(Up to date at the time of writing, only listing the probable culprits)
  • What Operating System are you using (both controller, and any agents involved in the problem)?
Windows (10, and server 2019)

Reproduction steps

Simply put I have this pipeline:

pipeline {
    agent any
    stages {
        stage('Checkout') {
            steps {
                checkout([$class: 'GitSCM', branches: [[name: 'refs/remotes/origin/master']],
                extensions: [[$class: 'CloneOption', depth: 10, noTags: true, reference: '', shallow: true],
                [$class: 'RelativeTargetDirectory', relativeTargetDir: 'repo'],
                [$class: 'LocalBranch', localBranch: 'merge_result'],
                [$class: 'CleanBeforeCheckout'], [$class: 'PruneStaleBranch']],
                userRemoteConfigs: [[credentialsId: '*****', name: 'origin', refspec: '+refs/heads/master:refs/remotes/origin/master', url: 'git@gitlab.************']]])                
            }
        }
    }
}

Results

Expected result:

Checked out merge_result on origin/master both when launched via GitLab plugin and or manually.

Actual result:

When launched manually I have checked out local branch merge_result on origin/master. But when launched via GitLab plugin (via a comment on MR) no matter what is in checkout() params the local merge_result is on origin/$gitlabSourceBranch.

I couldn't find the described behavior in either GitLab plugin or Git plugin documentation (thus reporting it as bug) neither is this behavior desired for us.

forry avatar Apr 13 '21 10:04 forry

I tried to reproduce this issue in the environment with indicated Jenkins and plugins versions, but unfortunately, I didn't succeed. The only difference was that I used a Linux-based agent instead of Windows-based one, but I really doubt it matters in this case.

I triggered job created with provided pipeline script (with replacing credentialsId and url) using Push Events, MR Events, and Note Events (MR for test-feature to master branch) and in each case, local branch (merge_result) was tracking origin/master branch (defined in checkout method) as expected, not origin/$gitlabSourceBranch (origin/test-feature).

If you are still facing this issue and if it's possible, please provide some more information about the environment you are using.

ljackiewicz avatar Nov 02 '21 21:11 ljackiewicz