Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-57089

Tag fails with merge before build triggered by GitLab

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Critical Critical
    • git-plugin, gitlab-plugin
    • None
    • Jenkins 2.164.1
      Git client 2.7.6
      Git plugin 3.9.3
      GitLab Plugin 1.5.11

      Building a tag fails when 'merge before build' is configured.  Build is triggered by a push to GitLab.  The console output indicates a merge is attempted, however I believe it should be the same as when a new branch is pushed - which just checks out the revision.

      Here's what I see when a new branch is pushed:

      [EnvInject] - Loading node environment variables.
      [EnvInject] - Preparing an environment for the build.
      [EnvInject] - Keeping Jenkins system variables.
      [EnvInject] - Keeping Jenkins build variables.
      [EnvInject] - Evaluating the Groovy script content
      [EnvInject] - Injecting contributions.
      Building on master in workspace C:\jenkins\workspace\merge_test
      [EnvInject] - Unset unresolved 'USERNAME' variable.
      [WS-CLEANUP] Deleting project workspace...
      [WS-CLEANUP] Deferred wipeout is used...
      [WS-CLEANUP] Done
      using credential f8a5a716-639d-4483-af01-f054e9ccbcc5
      Cloning the remote Git repository
      Cloning repository git@st-gitlab.apsautobag.com:APS/test_jenkins.git
       > git.exe init C:\jenkins\workspace\merge_test # timeout=10
      Fetching upstream changes from git@st-gitlab.apsautobag.com:APS/test_jenkins.git
       > git.exe --version # timeout=10
      using GIT_SSH to set credentials Repository authentication for GitLab
       > git.exe fetch --tags --force --progress git@st-gitlab.apsautobag.com:APS/test_jenkins.git +refs/heads/*:refs/remotes/origin/*
       > git.exe config remote.origin.url git@st-gitlab.apsautobag.com:APS/test_jenkins.git # timeout=10
       > git.exe config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10
       > git.exe config remote.origin.url git@st-gitlab.apsautobag.com:APS/test_jenkins.git # timeout=10
      Fetching upstream changes from git@st-gitlab.apsautobag.com:APS/test_jenkins.git
      using GIT_SSH to set credentials Repository authentication for GitLab
       > git.exe fetch --tags --force --progress git@st-gitlab.apsautobag.com:APS/test_jenkins.git +refs/heads/*:refs/remotes/origin/* +refs/merge-requests/*/head:refs/remotes/origin/merge-requests/* +refs/tags/*:refs/remotes/origin/tags/*
       > git.exe rev-parse "remotes/origin/develop^{commit}" # timeout=10
       > git.exe branch -a -v --no-abbrev --contains e41c8438b086f1aded8dc8e6f94227915fe846ed # timeout=10
      Checking out Revision e41c8438b086f1aded8dc8e6f94227915fe846ed (origin/develop)
       > git.exe config core.sparsecheckout # timeout=10
       > git.exe checkout -f e41c8438b086f1aded8dc8e6f94227915fe846ed
      Commit message: "Test change"
      First time build. Skipping changelog.
      [merge_test] $ cmd /c call C:\Windows\TEMP\jenkins8458950606275891551.bat
      

      Here's what happens when a tag is pushed:

      [EnvInject] - Loading node environment variables.
      [EnvInject] - Preparing an environment for the build.
      [EnvInject] - Keeping Jenkins system variables.
      [EnvInject] - Keeping Jenkins build variables.
      [EnvInject] - Evaluating the Groovy script content
      [EnvInject] - Injecting contributions.
      Building on master in workspace C:\jenkins\workspace\merge_test
      [EnvInject] - Unset unresolved 'USERNAME' variable.
      [WS-CLEANUP] Deleting project workspace...
      [WS-CLEANUP] Deferred wipeout is used...
      [WS-CLEANUP] Done
      using credential f8a5a716-639d-4483-af01-f054e9ccbcc5
      Cloning the remote Git repository
      Cloning repository git@st-gitlab.apsautobag.com:APS/test_jenkins.git
       > git.exe init C:\jenkins\workspace\merge_test # timeout=10
      Fetching upstream changes from git@st-gitlab.apsautobag.com:APS/test_jenkins.git
       > git.exe --version # timeout=10
      using GIT_SSH to set credentials Repository authentication for GitLab
       > git.exe fetch --tags --force --progress git@st-gitlab.apsautobag.com:APS/test_jenkins.git +refs/heads/*:refs/remotes/origin/*
       > git.exe config remote.origin.url git@st-gitlab.apsautobag.com:APS/test_jenkins.git # timeout=10
       > git.exe config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10
       > git.exe config remote.origin.url git@st-gitlab.apsautobag.com:APS/test_jenkins.git # timeout=10
      Fetching upstream changes from git@st-gitlab.apsautobag.com:APS/test_jenkins.git
      using GIT_SSH to set credentials Repository authentication for GitLab
       > git.exe fetch --tags --force --progress git@st-gitlab.apsautobag.com:APS/test_jenkins.git +refs/heads/*:refs/remotes/origin/* +refs/merge-requests/*/head:refs/remotes/origin/merge-requests/* +refs/tags/*:refs/remotes/origin/tags/*
       > git.exe rev-parse "refs/tags/0.1^{commit}" # timeout=10
       > git.exe branch -a -v --no-abbrev --contains 9971f7545e9729f215a3ad02b27e8b375252c2d0 # timeout=10
      Merging Revision 9971f7545e9729f215a3ad02b27e8b375252c2d0 (origin/tags/0.1, origin/master, origin/develop) to origin/refs/tags/0.1, UserMergeOptions{mergeRemote='origin', mergeTarget='refs/tags/0.1', mergeStrategy='default', fastForwardMode='--ff'}
       > git.exe rev-parse "origin/refs/tags/0.1^{commit}" # timeout=10
      FATAL: Command "git.exe rev-parse "origin/refs/tags/0.1^{commit}"" returned status code 128:
      stdout: origin/refs/tags/0.1^{commit}stderr: fatal: ambiguous argument 'origin/refs/tags/0.1^{commit}': unknown revision or path not in the working tree.
      Use '--' to separate paths from revisions, like this:
      'git <command> [<revision>...] -- [<file>...]'hudson.plugins.git.GitException: Command "git.exe rev-parse "origin/refs/tags/0.1^{commit}"" returned status code 128:
      stdout: origin/refs/tags/0.1^{commit}stderr: fatal: ambiguous argument 'origin/refs/tags/0.1^{commit}': unknown revision or path not in the working tree.
      Use '--' to separate paths from revisions, like this:
      'git <command> [<revision>...] -- [<file>...]'	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2042)
      	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2010)
      	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2006)
      	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommand(CliGitAPIImpl.java:1638)
      	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommand(CliGitAPIImpl.java:1650)
      	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.revParse(CliGitAPIImpl.java:835)
      	at hudson.plugins.git.GitAPI.revParse(GitAPI.java:316)
      	at hudson.plugins.git.extensions.impl.PreBuildMerge.decorateRevisionToBuild(PreBuildMerge.java:66)
      	at hudson.plugins.git.GitSCM.determineRevisionToBuild(GitSCM.java:1100)
      	at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1193)
      	at hudson.scm.SCM.checkout(SCM.java:504)
      	at hudson.model.AbstractProject.checkout(AbstractProject.java:1208)
      	at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:574)
      	at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
      	at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:499)
      	at hudson.model.Run.execute(Run.java:1816)
      	at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
      	at hudson.model.ResourceController.execute(ResourceController.java:97)
      	at hudson.model.Executor.run(Executor.java:429)
      [Slack Notifications] found #2 as previous completed, non-aborted build
      [Slack Notifications] will send OnSingleFailureNotification because build matches and user preferences allow it
      Finished: FAILURE

      With a tag I think PreBuildMerge() should determine there is no branch to merge and just check out the revision - same as what happens for a new branch.

      Here's my job configuration:

      refspec is: 

      +refs/heads/*:refs/remotes/origin/* +refs/merge-requests/*/head:refs/remotes/origin/merge-requests/* +refs/tags/*:refs/remotes/origin/tags/* 

       

            Unassigned Unassigned
            keno Ken Overly
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: