This issue is just for documentation, since the issue went away with the update to gitlab-branch-source 1.4.4. Before that, a merge request would do a "fat" instead a lightweight checkout to read the Jenkinsfile and I cannot reproduce the issue when just a lightweight checkout is done.

      Pipeline sample code to have something to talk about:

      def repo = checkout scm
      echo repo.GIT_COMMIT
      

      This works correctly for branch builds, but not for merge request builds and the strategy "Merging the merge request with the current target branch revision" - when using that strategy, GIT_COMMIT points to a revision which doesn't exist after the merge, but instead to the merge commit from the "temporary" chechout which was done for reading the Jenkinsfile. Relevant log snippets:

      Branch indexing
      Querying the current revision of merge request #3...
      Current revision of merge request #3 is 367f5bc9835cecaf5929cf9a6a8d3600ad1dae32
      Checking out git https://<REPO>.git into /var/lib/jenkins/workspace/SOMETHING_MR-3@script to read Jenkinsfile
      [...]
       > git fetch --no-tags --force --progress -- https://<REPO>.git +refs/merge-requests/3/head:refs/remotes/origin/MR-3 +refs/heads/master:refs/remotes/origin/master # timeout=10
      Merging remotes/origin/master commit eb6a5804b1a07157304d00562a489437342049e1 into MR head commit 367f5bc9835cecaf5929cf9a6a8d3600ad1dae32
      [...]
      Merge succeeded, producing a9473d5a2d79ace679affe37853e74950602b07b
      Checking out Revision a9473d5a2d79ace679affe37853e74950602b07b (feature/update-slf4j)
      [...]
      Commit message: "Merge commit 'eb6a5804b1a07157304d00562a489437342049e1' into HEAD"
      [GitLab Pipeline Status] Notifying merge request build status: RUNNING tgruetzm/versions/ci/MR-3: Build started...
      [GitLab Pipeline Status] Notified
      Running in Durability level: PERFORMANCE_OPTIMIZED
      [...]
      [GitLab Pipeline Status] Notifying merge request build status: RUNNING tgruetzm/versions/ci/MR-3: Build started...
      [Pipeline] Start of Pipeline
      [...]
      [Pipeline] checkout
      [...]
      Merging remotes/origin/master commit eb6a5804b1a07157304d00562a489437342049e1 into MR head commit 367f5bc9835cecaf5929cf9a6a8d3600ad1dae32
      [...]
      Merge succeeded, producing bdabb0071fa91fe128c037a9f3352b459fcfcde8
      Checking out Revision bdabb0071fa91fe128c037a9f3352b459fcfcde8 (feature/update-slf4j)
      [...]
      Commit message: "Merge commit 'eb6a5804b1a07157304d00562a489437342049e1' into HEAD"
      First time build. Skipping changelog.
      [...]
      [Pipeline] echo
      {GIT_AUTHOR_EMAIL=xxx, GIT_AUTHOR_NAME=xxx, GIT_BRANCH=feature/update-slf4j, GIT_COMMIT=a9473d5a2d79ace679affe37853e74950602b07b, GIT_COMMITTER_EMAIL=xxx, GIT_COMMITTER_NAME=xxx, GIT_LOCAL_BRANCH=feature/update-slf4j, GIT_PREVIOUS_COMMIT=873ac16b7ac3b44ad9b45cdde7479a3dd73a4beb, GIT_PREVIOUS_SUCCESSFUL_COMMIT=367f5bc9835cecaf5929cf9a6a8d3600ad1dae32, GIT_URL=https://<REPO>.git}
      [...]
      + git log --oneline -2
      bdabb00 Merge commit 'eb6a5804b1a07157304d00562a489437342049e1' into HEAD
      eb6a580 Update test output
      [...]
      

      Now, with a lightweight checkout:

      Started by user Tobias Gruetzmacher
      Querying the current revision of merge request #3...
      Current revision of merge request #3 is 367f5bc9835cecaf5929cf9a6a8d3600ad1dae32
      Obtained Jenkinsfile from eb6a5804b1a07157304d00562a489437342049e1+367f5bc9835cecaf5929cf9a6a8d3600ad1dae32
      Running in Durability level: PERFORMANCE_OPTIMIZED
      [...]
      [GitLab Pipeline Status] Notifying merge request build status: RUNNING tgruetzm/versions/ci/MR-3: Build started...
      [GitLab Pipeline Status] Notified
      [Pipeline] Start of Pipeline
      [...]
      [Pipeline] checkout
      [...]
      Merging remotes/origin/master commit eb6a5804b1a07157304d00562a489437342049e1 into MR head commit 367f5bc9835cecaf5929cf9a6a8d3600ad1dae32
      [...]
      Merge succeeded, producing 793df539d53a54cb84316c39f81939c344255e4b
      Checking out Revision 793df539d53a54cb84316c39f81939c344255e4b (feature/update-slf4j)
      [...]
      Commit message: "Merge commit 'eb6a5804b1a07157304d00562a489437342049e1' into HEAD"
      First time build. Skipping changelog.
      [...]
      [Pipeline] echo
      {GIT_AUTHOR_EMAIL=xxx, GIT_AUTHOR_NAME=xxx, GIT_BRANCH=feature/update-slf4j, GIT_COMMIT=793df539d53a54cb84316c39f81939c344255e4b, GIT_COMMITTER_EMAIL=xxx, GIT_COMMITTER_NAME=xxx, GIT_LOCAL_BRANCH=feature/update-slf4j, GIT_PREVIOUS_COMMIT=a9473d5a2d79ace679affe37853e74950602b07b, GIT_PREVIOUS_SUCCESSFUL_COMMIT=367f5bc9835cecaf5929cf9a6a8d3600ad1dae32, GIT_URL=https://<REPO>.git}
      [...]
      + git log --oneline -2
      793df53 Merge commit 'eb6a5804b1a07157304d00562a489437342049e1' into HEAD
      eb6a580 Update test output
      [...]
      

          [JENKINS-61067] Wrong value for GIT_COMMIT after merge?

          Tobias Gruetzmacher created issue -
          Tobias Gruetzmacher made changes -
          Description Original: This issue is just for documentation, since the issue went away with the update to gitlab-branch-source [1.4.4](https://github.com/jenkinsci/gitlab-branch-source-plugin/releases/tag/gitlab-branch-source-1.4.4). Before that, a merge request would do a "fat" instead a lightweight checkout to read the {{Jenkinsfile}} and I cannot reproduce the issue when just a lightweight checkout is done.

          Pipeline sample code to have somethingto talk about:

          {code:java}
          def repo = checkout scm
          echo repo.GIT_COMMIT
          {code}

          This works correctly for branch builds, but not for merge request builds and the strategy "Merging the merge request with the current target branch revision" - when using that strategy, {{GIT_COMMIT}} points to a revision which doesn't exist after the merge, but instead to the merge commit from the "temporary" chechout which was done for reading the {{Jenkinsfile}}. Relevant log snippets:

          {noformat}
          Branch indexing
          Querying the current revision of merge request #3...
          Current revision of merge request #3 is 367f5bc9835cecaf5929cf9a6a8d3600ad1dae32
          Checking out git https://&lt;REPO&gt;.git into /var/lib/jenkins/workspace/SOMETHING_MR-3@script to read Jenkinsfile
          [...]
           > git fetch --no-tags --force --progress -- https://&lt;REPO&gt;.git +refs/merge-requests/3/head:refs/remotes/origin/MR-3 +refs/heads/master:refs/remotes/origin/master # timeout=10
          Merging remotes/origin/master commit eb6a5804b1a07157304d00562a489437342049e1 into MR head commit 367f5bc9835cecaf5929cf9a6a8d3600ad1dae32
          [...]
          Merge succeeded, producing a9473d5a2d79ace679affe37853e74950602b07b
          Checking out Revision a9473d5a2d79ace679affe37853e74950602b07b (feature/update-slf4j)
          [...]
          Commit message: "Merge commit 'eb6a5804b1a07157304d00562a489437342049e1' into HEAD"
          [GitLab Pipeline Status] Notifying merge request build status: RUNNING tgruetzm/versions/ci/MR-3: Build started...
          [GitLab Pipeline Status] Notified
          Running in Durability level: PERFORMANCE_OPTIMIZED
          [...]
          [GitLab Pipeline Status] Notifying merge request build status: RUNNING tgruetzm/versions/ci/MR-3: Build started...
          [Pipeline] Start of Pipeline
          [...]
          [Pipeline] checkout
          [...]
          Merging remotes/origin/master commit eb6a5804b1a07157304d00562a489437342049e1 into MR head commit 367f5bc9835cecaf5929cf9a6a8d3600ad1dae32
          [...]
          Merge succeeded, producing bdabb0071fa91fe128c037a9f3352b459fcfcde8
          Checking out Revision bdabb0071fa91fe128c037a9f3352b459fcfcde8 (feature/update-slf4j)
          [...]
          Commit message: "Merge commit 'eb6a5804b1a07157304d00562a489437342049e1' into HEAD"
          First time build. Skipping changelog.
          [...]
          [Pipeline] echo
          {GIT_AUTHOR_EMAIL=someidiot@inform-software.com, GIT_AUTHOR_NAME=Test-Jenkins, GIT_BRANCH=feature/update-slf4j, GIT_COMMIT=a9473d5a2d79ace679affe37853e74950602b07b, GIT_COMMITTER_EMAIL=someidiot@inform-software.com, GIT_COMMITTER_NAME=Test-Jenkins, GIT_LOCAL_BRANCH=feature/update-slf4j, GIT_PREVIOUS_COMMIT=873ac16b7ac3b44ad9b45cdde7479a3dd73a4beb, GIT_PREVIOUS_SUCCESSFUL_COMMIT=367f5bc9835cecaf5929cf9a6a8d3600ad1dae32, GIT_URL=https://&lt;REPO&gt;.git}
          [...]
          + git log --oneline -2
          bdabb00 Merge commit 'eb6a5804b1a07157304d00562a489437342049e1' into HEAD
          eb6a580 Update test output
          [...]
          {noformat}

          Now, with a lightweight checkout:
          {noformat}
          Started by user Tobias Gruetzmacher
          Querying the current revision of merge request #3...
          Current revision of merge request #3 is 367f5bc9835cecaf5929cf9a6a8d3600ad1dae32
          Obtained Jenkinsfile from eb6a5804b1a07157304d00562a489437342049e1+367f5bc9835cecaf5929cf9a6a8d3600ad1dae32
          Running in Durability level: PERFORMANCE_OPTIMIZED
          [...]
          [GitLab Pipeline Status] Notifying merge request build status: RUNNING tgruetzm/versions/ci/MR-3: Build started...
          [GitLab Pipeline Status] Notified
          [Pipeline] Start of Pipeline
          [...]
          [Pipeline] checkout
          [...]
          Merging remotes/origin/master commit eb6a5804b1a07157304d00562a489437342049e1 into MR head commit 367f5bc9835cecaf5929cf9a6a8d3600ad1dae32
          [...]
          Merge succeeded, producing 793df539d53a54cb84316c39f81939c344255e4b
          Checking out Revision 793df539d53a54cb84316c39f81939c344255e4b (feature/update-slf4j)
          [...]
          Commit message: "Merge commit 'eb6a5804b1a07157304d00562a489437342049e1' into HEAD"
          First time build. Skipping changelog.
          [...]
          [Pipeline] echo
          {GIT_AUTHOR_EMAIL=someidiot@inform-software.com, GIT_AUTHOR_NAME=Test-Jenkins, GIT_BRANCH=feature/update-slf4j, GIT_COMMIT=793df539d53a54cb84316c39f81939c344255e4b, GIT_COMMITTER_EMAIL=someidiot@inform-software.com, GIT_COMMITTER_NAME=Test-Jenkins, GIT_LOCAL_BRANCH=feature/update-slf4j, GIT_PREVIOUS_COMMIT=a9473d5a2d79ace679affe37853e74950602b07b, GIT_PREVIOUS_SUCCESSFUL_COMMIT=367f5bc9835cecaf5929cf9a6a8d3600ad1dae32, GIT_URL=https://git.inform-software.com/tgruetzm/versions.git}
          [...]
          + git log --oneline -2
          793df53 Merge commit 'eb6a5804b1a07157304d00562a489437342049e1' into HEAD
          eb6a580 Update test output
          [...]
          {noformat}
          New: This issue is just for documentation, since the issue went away with the update to gitlab-branch-source [1.4.4|https://github.com/jenkinsci/gitlab-branch-source-plugin/releases/tag/gitlab-branch-source-1.4.4]. Before that, a merge request would do a "fat" instead a lightweight checkout to read the {{Jenkinsfile}} and I cannot reproduce the issue when just a lightweight checkout is done.

          Pipeline sample code to have something to talk about:

          {code:java}
          def repo = checkout scm
          echo repo.GIT_COMMIT
          {code}

          This works correctly for branch builds, but not for merge request builds and the strategy "Merging the merge request with the current target branch revision" - when using that strategy, {{GIT_COMMIT}} points to a revision which doesn't exist after the merge, but instead to the merge commit from the "temporary" chechout which was done for reading the {{Jenkinsfile}}. Relevant log snippets:

          {noformat}
          Branch indexing
          Querying the current revision of merge request #3...
          Current revision of merge request #3 is 367f5bc9835cecaf5929cf9a6a8d3600ad1dae32
          Checking out git https://&lt;REPO&gt;.git into /var/lib/jenkins/workspace/SOMETHING_MR-3@script to read Jenkinsfile
          [...]
           > git fetch --no-tags --force --progress -- https://&lt;REPO&gt;.git +refs/merge-requests/3/head:refs/remotes/origin/MR-3 +refs/heads/master:refs/remotes/origin/master # timeout=10
          Merging remotes/origin/master commit eb6a5804b1a07157304d00562a489437342049e1 into MR head commit 367f5bc9835cecaf5929cf9a6a8d3600ad1dae32
          [...]
          Merge succeeded, producing a9473d5a2d79ace679affe37853e74950602b07b
          Checking out Revision a9473d5a2d79ace679affe37853e74950602b07b (feature/update-slf4j)
          [...]
          Commit message: "Merge commit 'eb6a5804b1a07157304d00562a489437342049e1' into HEAD"
          [GitLab Pipeline Status] Notifying merge request build status: RUNNING tgruetzm/versions/ci/MR-3: Build started...
          [GitLab Pipeline Status] Notified
          Running in Durability level: PERFORMANCE_OPTIMIZED
          [...]
          [GitLab Pipeline Status] Notifying merge request build status: RUNNING tgruetzm/versions/ci/MR-3: Build started...
          [Pipeline] Start of Pipeline
          [...]
          [Pipeline] checkout
          [...]
          Merging remotes/origin/master commit eb6a5804b1a07157304d00562a489437342049e1 into MR head commit 367f5bc9835cecaf5929cf9a6a8d3600ad1dae32
          [...]
          Merge succeeded, producing bdabb0071fa91fe128c037a9f3352b459fcfcde8
          Checking out Revision bdabb0071fa91fe128c037a9f3352b459fcfcde8 (feature/update-slf4j)
          [...]
          Commit message: "Merge commit 'eb6a5804b1a07157304d00562a489437342049e1' into HEAD"
          First time build. Skipping changelog.
          [...]
          [Pipeline] echo
          {GIT_AUTHOR_EMAIL=someidiot@inform-software.com, GIT_AUTHOR_NAME=Test-Jenkins, GIT_BRANCH=feature/update-slf4j, GIT_COMMIT=a9473d5a2d79ace679affe37853e74950602b07b, GIT_COMMITTER_EMAIL=someidiot@inform-software.com, GIT_COMMITTER_NAME=Test-Jenkins, GIT_LOCAL_BRANCH=feature/update-slf4j, GIT_PREVIOUS_COMMIT=873ac16b7ac3b44ad9b45cdde7479a3dd73a4beb, GIT_PREVIOUS_SUCCESSFUL_COMMIT=367f5bc9835cecaf5929cf9a6a8d3600ad1dae32, GIT_URL=https://&lt;REPO&gt;.git}
          [...]
          + git log --oneline -2
          bdabb00 Merge commit 'eb6a5804b1a07157304d00562a489437342049e1' into HEAD
          eb6a580 Update test output
          [...]
          {noformat}

          Now, with a lightweight checkout:
          {noformat}
          Started by user Tobias Gruetzmacher
          Querying the current revision of merge request #3...
          Current revision of merge request #3 is 367f5bc9835cecaf5929cf9a6a8d3600ad1dae32
          Obtained Jenkinsfile from eb6a5804b1a07157304d00562a489437342049e1+367f5bc9835cecaf5929cf9a6a8d3600ad1dae32
          Running in Durability level: PERFORMANCE_OPTIMIZED
          [...]
          [GitLab Pipeline Status] Notifying merge request build status: RUNNING tgruetzm/versions/ci/MR-3: Build started...
          [GitLab Pipeline Status] Notified
          [Pipeline] Start of Pipeline
          [...]
          [Pipeline] checkout
          [...]
          Merging remotes/origin/master commit eb6a5804b1a07157304d00562a489437342049e1 into MR head commit 367f5bc9835cecaf5929cf9a6a8d3600ad1dae32
          [...]
          Merge succeeded, producing 793df539d53a54cb84316c39f81939c344255e4b
          Checking out Revision 793df539d53a54cb84316c39f81939c344255e4b (feature/update-slf4j)
          [...]
          Commit message: "Merge commit 'eb6a5804b1a07157304d00562a489437342049e1' into HEAD"
          First time build. Skipping changelog.
          [...]
          [Pipeline] echo
          {GIT_AUTHOR_EMAIL=someidiot@inform-software.com, GIT_AUTHOR_NAME=Test-Jenkins, GIT_BRANCH=feature/update-slf4j, GIT_COMMIT=793df539d53a54cb84316c39f81939c344255e4b, GIT_COMMITTER_EMAIL=someidiot@inform-software.com, GIT_COMMITTER_NAME=Test-Jenkins, GIT_LOCAL_BRANCH=feature/update-slf4j, GIT_PREVIOUS_COMMIT=a9473d5a2d79ace679affe37853e74950602b07b, GIT_PREVIOUS_SUCCESSFUL_COMMIT=367f5bc9835cecaf5929cf9a6a8d3600ad1dae32, GIT_URL=https://git.inform-software.com/tgruetzm/versions.git}
          [...]
          + git log --oneline -2
          793df53 Merge commit 'eb6a5804b1a07157304d00562a489437342049e1' into HEAD
          eb6a580 Update test output
          [...]
          {noformat}
          Tobias Gruetzmacher made changes -
          Description Original: This issue is just for documentation, since the issue went away with the update to gitlab-branch-source [1.4.4|https://github.com/jenkinsci/gitlab-branch-source-plugin/releases/tag/gitlab-branch-source-1.4.4]. Before that, a merge request would do a "fat" instead a lightweight checkout to read the {{Jenkinsfile}} and I cannot reproduce the issue when just a lightweight checkout is done.

          Pipeline sample code to have something to talk about:

          {code:java}
          def repo = checkout scm
          echo repo.GIT_COMMIT
          {code}

          This works correctly for branch builds, but not for merge request builds and the strategy "Merging the merge request with the current target branch revision" - when using that strategy, {{GIT_COMMIT}} points to a revision which doesn't exist after the merge, but instead to the merge commit from the "temporary" chechout which was done for reading the {{Jenkinsfile}}. Relevant log snippets:

          {noformat}
          Branch indexing
          Querying the current revision of merge request #3...
          Current revision of merge request #3 is 367f5bc9835cecaf5929cf9a6a8d3600ad1dae32
          Checking out git https://&lt;REPO&gt;.git into /var/lib/jenkins/workspace/SOMETHING_MR-3@script to read Jenkinsfile
          [...]
           > git fetch --no-tags --force --progress -- https://&lt;REPO&gt;.git +refs/merge-requests/3/head:refs/remotes/origin/MR-3 +refs/heads/master:refs/remotes/origin/master # timeout=10
          Merging remotes/origin/master commit eb6a5804b1a07157304d00562a489437342049e1 into MR head commit 367f5bc9835cecaf5929cf9a6a8d3600ad1dae32
          [...]
          Merge succeeded, producing a9473d5a2d79ace679affe37853e74950602b07b
          Checking out Revision a9473d5a2d79ace679affe37853e74950602b07b (feature/update-slf4j)
          [...]
          Commit message: "Merge commit 'eb6a5804b1a07157304d00562a489437342049e1' into HEAD"
          [GitLab Pipeline Status] Notifying merge request build status: RUNNING tgruetzm/versions/ci/MR-3: Build started...
          [GitLab Pipeline Status] Notified
          Running in Durability level: PERFORMANCE_OPTIMIZED
          [...]
          [GitLab Pipeline Status] Notifying merge request build status: RUNNING tgruetzm/versions/ci/MR-3: Build started...
          [Pipeline] Start of Pipeline
          [...]
          [Pipeline] checkout
          [...]
          Merging remotes/origin/master commit eb6a5804b1a07157304d00562a489437342049e1 into MR head commit 367f5bc9835cecaf5929cf9a6a8d3600ad1dae32
          [...]
          Merge succeeded, producing bdabb0071fa91fe128c037a9f3352b459fcfcde8
          Checking out Revision bdabb0071fa91fe128c037a9f3352b459fcfcde8 (feature/update-slf4j)
          [...]
          Commit message: "Merge commit 'eb6a5804b1a07157304d00562a489437342049e1' into HEAD"
          First time build. Skipping changelog.
          [...]
          [Pipeline] echo
          {GIT_AUTHOR_EMAIL=someidiot@inform-software.com, GIT_AUTHOR_NAME=Test-Jenkins, GIT_BRANCH=feature/update-slf4j, GIT_COMMIT=a9473d5a2d79ace679affe37853e74950602b07b, GIT_COMMITTER_EMAIL=someidiot@inform-software.com, GIT_COMMITTER_NAME=Test-Jenkins, GIT_LOCAL_BRANCH=feature/update-slf4j, GIT_PREVIOUS_COMMIT=873ac16b7ac3b44ad9b45cdde7479a3dd73a4beb, GIT_PREVIOUS_SUCCESSFUL_COMMIT=367f5bc9835cecaf5929cf9a6a8d3600ad1dae32, GIT_URL=https://&lt;REPO&gt;.git}
          [...]
          + git log --oneline -2
          bdabb00 Merge commit 'eb6a5804b1a07157304d00562a489437342049e1' into HEAD
          eb6a580 Update test output
          [...]
          {noformat}

          Now, with a lightweight checkout:
          {noformat}
          Started by user Tobias Gruetzmacher
          Querying the current revision of merge request #3...
          Current revision of merge request #3 is 367f5bc9835cecaf5929cf9a6a8d3600ad1dae32
          Obtained Jenkinsfile from eb6a5804b1a07157304d00562a489437342049e1+367f5bc9835cecaf5929cf9a6a8d3600ad1dae32
          Running in Durability level: PERFORMANCE_OPTIMIZED
          [...]
          [GitLab Pipeline Status] Notifying merge request build status: RUNNING tgruetzm/versions/ci/MR-3: Build started...
          [GitLab Pipeline Status] Notified
          [Pipeline] Start of Pipeline
          [...]
          [Pipeline] checkout
          [...]
          Merging remotes/origin/master commit eb6a5804b1a07157304d00562a489437342049e1 into MR head commit 367f5bc9835cecaf5929cf9a6a8d3600ad1dae32
          [...]
          Merge succeeded, producing 793df539d53a54cb84316c39f81939c344255e4b
          Checking out Revision 793df539d53a54cb84316c39f81939c344255e4b (feature/update-slf4j)
          [...]
          Commit message: "Merge commit 'eb6a5804b1a07157304d00562a489437342049e1' into HEAD"
          First time build. Skipping changelog.
          [...]
          [Pipeline] echo
          {GIT_AUTHOR_EMAIL=someidiot@inform-software.com, GIT_AUTHOR_NAME=Test-Jenkins, GIT_BRANCH=feature/update-slf4j, GIT_COMMIT=793df539d53a54cb84316c39f81939c344255e4b, GIT_COMMITTER_EMAIL=someidiot@inform-software.com, GIT_COMMITTER_NAME=Test-Jenkins, GIT_LOCAL_BRANCH=feature/update-slf4j, GIT_PREVIOUS_COMMIT=a9473d5a2d79ace679affe37853e74950602b07b, GIT_PREVIOUS_SUCCESSFUL_COMMIT=367f5bc9835cecaf5929cf9a6a8d3600ad1dae32, GIT_URL=https://git.inform-software.com/tgruetzm/versions.git}
          [...]
          + git log --oneline -2
          793df53 Merge commit 'eb6a5804b1a07157304d00562a489437342049e1' into HEAD
          eb6a580 Update test output
          [...]
          {noformat}
          New: This issue is just for documentation, since the issue went away with the update to gitlab-branch-source [1.4.4|https://github.com/jenkinsci/gitlab-branch-source-plugin/releases/tag/gitlab-branch-source-1.4.4]. Before that, a merge request would do a "fat" instead a lightweight checkout to read the {{Jenkinsfile}} and I cannot reproduce the issue when just a lightweight checkout is done.

          Pipeline sample code to have something to talk about:

          {code:java}
          def repo = checkout scm
          echo repo.GIT_COMMIT
          {code}

          This works correctly for branch builds, but not for merge request builds and the strategy "Merging the merge request with the current target branch revision" - when using that strategy, {{GIT_COMMIT}} points to a revision which doesn't exist after the merge, but instead to the merge commit from the "temporary" chechout which was done for reading the {{Jenkinsfile}}. Relevant log snippets:

          {noformat}
          Branch indexing
          Querying the current revision of merge request #3...
          Current revision of merge request #3 is 367f5bc9835cecaf5929cf9a6a8d3600ad1dae32
          Checking out git https://&lt;REPO&gt;.git into /var/lib/jenkins/workspace/SOMETHING_MR-3@script to read Jenkinsfile
          [...]
           > git fetch --no-tags --force --progress -- https://&lt;REPO&gt;.git +refs/merge-requests/3/head:refs/remotes/origin/MR-3 +refs/heads/master:refs/remotes/origin/master # timeout=10
          Merging remotes/origin/master commit eb6a5804b1a07157304d00562a489437342049e1 into MR head commit 367f5bc9835cecaf5929cf9a6a8d3600ad1dae32
          [...]
          Merge succeeded, producing a9473d5a2d79ace679affe37853e74950602b07b
          Checking out Revision a9473d5a2d79ace679affe37853e74950602b07b (feature/update-slf4j)
          [...]
          Commit message: "Merge commit 'eb6a5804b1a07157304d00562a489437342049e1' into HEAD"
          [GitLab Pipeline Status] Notifying merge request build status: RUNNING tgruetzm/versions/ci/MR-3: Build started...
          [GitLab Pipeline Status] Notified
          Running in Durability level: PERFORMANCE_OPTIMIZED
          [...]
          [GitLab Pipeline Status] Notifying merge request build status: RUNNING tgruetzm/versions/ci/MR-3: Build started...
          [Pipeline] Start of Pipeline
          [...]
          [Pipeline] checkout
          [...]
          Merging remotes/origin/master commit eb6a5804b1a07157304d00562a489437342049e1 into MR head commit 367f5bc9835cecaf5929cf9a6a8d3600ad1dae32
          [...]
          Merge succeeded, producing bdabb0071fa91fe128c037a9f3352b459fcfcde8
          Checking out Revision bdabb0071fa91fe128c037a9f3352b459fcfcde8 (feature/update-slf4j)
          [...]
          Commit message: "Merge commit 'eb6a5804b1a07157304d00562a489437342049e1' into HEAD"
          First time build. Skipping changelog.
          [...]
          [Pipeline] echo
          {GIT_AUTHOR_EMAIL=xxx, GIT_AUTHOR_NAME=xxx, GIT_BRANCH=feature/update-slf4j, GIT_COMMIT=a9473d5a2d79ace679affe37853e74950602b07b, GIT_COMMITTER_EMAIL=xxx, GIT_COMMITTER_NAME=xxx, GIT_LOCAL_BRANCH=feature/update-slf4j, GIT_PREVIOUS_COMMIT=873ac16b7ac3b44ad9b45cdde7479a3dd73a4beb, GIT_PREVIOUS_SUCCESSFUL_COMMIT=367f5bc9835cecaf5929cf9a6a8d3600ad1dae32, GIT_URL=https://&lt;REPO&gt;.git}
          [...]
          + git log --oneline -2
          bdabb00 Merge commit 'eb6a5804b1a07157304d00562a489437342049e1' into HEAD
          eb6a580 Update test output
          [...]
          {noformat}

          Now, with a lightweight checkout:
          {noformat}
          Started by user Tobias Gruetzmacher
          Querying the current revision of merge request #3...
          Current revision of merge request #3 is 367f5bc9835cecaf5929cf9a6a8d3600ad1dae32
          Obtained Jenkinsfile from eb6a5804b1a07157304d00562a489437342049e1+367f5bc9835cecaf5929cf9a6a8d3600ad1dae32
          Running in Durability level: PERFORMANCE_OPTIMIZED
          [...]
          [GitLab Pipeline Status] Notifying merge request build status: RUNNING tgruetzm/versions/ci/MR-3: Build started...
          [GitLab Pipeline Status] Notified
          [Pipeline] Start of Pipeline
          [...]
          [Pipeline] checkout
          [...]
          Merging remotes/origin/master commit eb6a5804b1a07157304d00562a489437342049e1 into MR head commit 367f5bc9835cecaf5929cf9a6a8d3600ad1dae32
          [...]
          Merge succeeded, producing 793df539d53a54cb84316c39f81939c344255e4b
          Checking out Revision 793df539d53a54cb84316c39f81939c344255e4b (feature/update-slf4j)
          [...]
          Commit message: "Merge commit 'eb6a5804b1a07157304d00562a489437342049e1' into HEAD"
          First time build. Skipping changelog.
          [...]
          [Pipeline] echo
          {GIT_AUTHOR_EMAIL=xxx, GIT_AUTHOR_NAME=xxx, GIT_BRANCH=feature/update-slf4j, GIT_COMMIT=793df539d53a54cb84316c39f81939c344255e4b, GIT_COMMITTER_EMAIL=xxx, GIT_COMMITTER_NAME=xxx, GIT_LOCAL_BRANCH=feature/update-slf4j, GIT_PREVIOUS_COMMIT=a9473d5a2d79ace679affe37853e74950602b07b, GIT_PREVIOUS_SUCCESSFUL_COMMIT=367f5bc9835cecaf5929cf9a6a8d3600ad1dae32, GIT_URL=https://&lt;REPO&gt;.git}
          [...]
          + git log --oneline -2
          793df53 Merge commit 'eb6a5804b1a07157304d00562a489437342049e1' into HEAD
          eb6a580 Update test output
          [...]
          {noformat}
          Mark Waite made changes -
          Assignee Original: Mark Waite [ markewaite ]
          Mark Waite made changes -
          Labels New: newbie-friendly
          Ing. Christoph Obexer made changes -
          Priority Original: Minor [ 4 ] New: Major [ 3 ]
          Ing. Christoph Obexer made changes -
          Assignee New: Rick [ surenpi ]
          Mark Waite made changes -
          Assignee Original: Rick [ surenpi ]
          Mark Waite made changes -
          Labels Original: newbie-friendly

            Unassigned Unassigned
            tgr Tobias Gruetzmacher
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: