• Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • None
    • Jenkins Version 2.235.1
      multibranch-pipeline
      bitbucket-branch-source-plugin
      git-plugin

      We are using a multibranch pipeline set up to get the pipeline from a Jenkinfile within the repository.

      The current configuration is:
      Discover branches: Exclude branches that are also filled as PRs
      Discover pull requests from origin: Merging the pull request with the current target branch revision
      Filter by name: .master|.*release/.|.PR-. (here if I don't include the pr part no prs are built)
      Clean before checkout
      Sparse Checkout (with about 6 different paths)
      Property Strategy All branches get the same properties

      Currently on PR Builds the env variable for the commit id, and previous commit id for that matter, are not valid commits in the Bitbucket repository.
      The commit id that shows on the blue ocean page is correct, the short version of commit iv, but it is in fact the last commit on source branch.

      Is this an expected behavior?

      As a side note PR changes are not reported on the first build (should this changeset include de diff between source branch and target branch)?

          [JENKINS-62783] Wrong Commit ID in Pull Request Builds

          Marie-Helene Touchette added a comment - - edited

          I'm seeing the same behavior.

          And unfortunately, the last commit id from the change-branch (as seen in blue-ocean) is nowhere to be found in the pipeline's environment variables.

          Instead, we are stuck with an unknown commit id, probably originating from the merge being done locally in the merge-PR-branch.

          I see this as a bug...

          Marie-Helene Touchette added a comment - - edited I'm seeing the same behavior. And unfortunately, the last commit id from the change-branch (as seen in blue-ocean) is nowhere to be found in the pipeline's environment variables. Instead, we are stuck with an unknown commit id, probably originating from the merge being done locally in the merge-PR-branch. I see this as a bug...

          Rishi added a comment -

          I am also stuck on same issue. Has this any solution? 

          I need commit ID from source branch in PR.

          Rishi added a comment - I am also stuck on same issue. Has this any solution?  I need commit ID from source branch in PR.

          Rishi added a comment -

          I used this code block to get correct COMMIT ID:

           

          stage("GET GIT COMMIT"){
              environment { 
                  MY_GIT_COMMIT = sh (returnStdout: true, script: "git log --pretty=oneline | awk 'NR==2{print \$1}'").trim()
              }
              steps{
                  sh 'echo $MY_GIT_COMMIT'
              }
          }
          

           

          Rishi added a comment - I used this code block to get correct COMMIT ID:   stage( "GET GIT COMMIT" ){ environment { MY_GIT_COMMIT = sh (returnStdout: true , script: "git log --pretty=oneline | awk 'NR==2{print \$1}' " ).trim() } steps{ sh 'echo $MY_GIT_COMMIT' } }  

          This seems to be the desired behavior with "merging the pull request with the current target branch"? Or especially if the branch/PR is outdated from the master branch?

          Günter Grodotzki added a comment - This seems to be the desired behavior with "merging the pull request with the current target branch"? Or especially if the branch/PR is outdated from the master branch?

            Unassigned Unassigned
            one_random_dev Random Dev
            Votes:
            2 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: