Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can not checkout merge commit in Jenkins Pipeline #322

Open
kirilla111 opened this issue Jan 12, 2024 · 1 comment
Open

Can not checkout merge commit in Jenkins Pipeline #322

kirilla111 opened this issue Jan 12, 2024 · 1 comment

Comments

@kirilla111
Copy link

Hi,

Our team uses BB-server and pipeline configured to build on PR merge in master

Problem occurs when we use merge strategy "Merge commit --no-ff". Bitbucket sends:

{
  "eventKey": "pr:merged",
  "pullRequest": {
    "fromRef": {
      "id": "refs/heads/<branch>",
      "displayId": "test3",
      "latestCommit": "326eabb767f9bd19dfb510a81284142adad595a5",
    },
    "toRef": {
      "id": "refs/heads/master",
      "displayId": "master",
      "latestCommit": "43cd3eac23c2ad23fbe0586ad3e22259f15a841c",
    },
    "properties": {
      "mergeCommit": {
        "displayId": "8dc7e904f5d",
        "id": "144311b20df08572b13c3b4e20c72796e70e6d5c"
      }
    }
  }
}

So, we expect build under hash of commit merged in master: 144311b20df08572b13c3b4e20c72796e70e6d5c

But in facts scm step checkout commit from fromRef.lastestCommit (326eabb767f9bd19dfb510a81284142adad595a5)

And env.BITBUCKET_PAYLOAD has no information about properties.mergeCommit (144311b20df08572b13c3b4e20c72796e70e6d5c). So, we can`t checkout expected commit via git command.

Our Jenkins file (if needed):

properties([
        pipelineTriggers([
                bitBucketTrigger(
                        credentialsId: '<creds>',
                        triggers: [
                                [
                                        $class      : 'BitBucketPPRPullRequestServerTriggerFilter',
                                        actionFilter: [
                                                $class         : 'BitBucketPPRPullRequestServerMergedActionFilter',
                                                allowedBranches: 'master',
                                        ]
                                ]
                        ]
                )
        ])
])
pipeline {
    ...
     stages {
     ...
         stage("scm step") {
                steps {
                    dir("<dir>") {
                        script {
                            checkout scm: [
                                    $class           : 'GitSCM',
                                    branches         : [[name: "master"]],
                                    browser          : bitbucketServer("<url>"),
                                    userRemoteConfigs: [
                                            [
                                                    credentialsId: '<creds>',
                                                    url          : "<url>"
                                            ]
                                    ]
                            ]
                        }
                    }
                }
            }
    }
    ...
}

I`m tried different combinations of trigger and scm step configuration but result is always the same. Can you help?

@kirilla111 kirilla111 changed the title Can not checkout merge commit is Jenkins Pipeline Can not checkout merge commit in Jenkins Pipeline Jan 12, 2024
@Joakolguin
Copy link

Joakolguin commented Apr 17, 2024

Same issue here, with BB-Cloud.
Bitbucket payload has the Merge commit information, but the jenkins plugins doesn't capture that value.

Regards.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants