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

Jenkins Gitlab squash commit error stderr: fatal: ambiguous argument '^{commit}': unknown revision or path not in the working tree. Use '--' to separate paths from revisions, like this: 'git <command> [<revision>...] -- [<file>...]'

Open Petre7 opened this issue 5 years ago • 3 comments

When we merge with squash commit Jenkins fail with the following error `

09:27:56  stdout: d8fd53f8c5c1522678cfae1af81f2c61eb1ec8a3^{commit}
09:27:56  
09:27:56  stderr: fatal: ambiguous argument 'd8fd53f8c5c1522678cfae1af81f2c61eb1ec8a3^{commit}': unknown revision or path not in the working tree.
09:27:56  Use '--' to separate paths from revisions, like this:
09:27:56  'git <command> [<revision>...] -- [<file>...]```

However when we merge without squash commit, pipeline runs successful 
This issue happen when we checkout using gitlab plugin and below is the Jenkins checkout script

  checkout changelog: true, poll: true, scm: [
            $class: 'GitSCM',
            branches: [[name: "origin/${env.gitlabSourceBranch}"]],
            doGenerateSubmoduleConfigurations: false,
            extensions: [],
            submoduleCfg: [],
            userRemoteConfigs: [[
            credentialsId: "gitlab-ssh",
            url: gitlabTargetRepoSshUrl
            ]]
        ]
Please can you advise?

Petre7 avatar Apr 08 '20 21:04 Petre7

Hello same issue here !

Need to disable squash commit into the PR.

ktibi avatar Jun 04 '20 13:06 ktibi

Hey, same issue here, it only happens when I squash commits on merge requests.

hudson.plugins.git.GitException: Command "git rev-parse 98a6d794e986f081fcc1b6357502cf1ca8558d16^{commit}" returned status code 128:
stdout: 98a6d794e986f081fcc1b6357502cf1ca8558d16^{commit}

stderr: fatal: ambiguous argument '98a6d794e986f081fcc1b6357502cf1ca8558d16^{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:2671)
	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2601)
	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2597)
	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommand(CliGitAPIImpl.java:1968)
	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommand(CliGitAPIImpl.java:1980)
	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.revParse(CliGitAPIImpl.java:1082)
	at hudson.plugins.git.GitAPI.revParse(GitAPI.java:337)
	at hudson.plugins.git.RevisionParameterAction.toRevision(RevisionParameterAction.java:98)
	at hudson.plugins.git.GitSCM.determineRevisionToBuild(GitSCM.java:1140)
	at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1303)
	at org.jenkinsci.plugins.workflow.steps.scm.SCMStep.checkout(SCMStep.java:129)
	at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:97)
	at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:84)
	at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:829)
Finished: FAILURE

grzechup avatar Feb 14 '22 19:02 grzechup

Hello, Also experiencing this issue. Is there any w/a till it will be solved?

stanislr avatar Sep 04 '22 08:09 stanislr

In my case, this error happened because in my merge requests I've checked the option "Delete source branch when merge request is accepted". Since your branch is deleted when merge request is accepted and gitlab webhook event has a reference to your last commit in that branch, this error is triggered.

A workaround would be probably to delete the branch via REST API in post-steps in your Jenkinsfile.

bzbikowski avatar Nov 22 '22 11:11 bzbikowski