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

Error adding commits to existing Merge Request #155

Closed
pbendersky opened this issue Dec 11, 2015 · 9 comments
Closed

Error adding commits to existing Merge Request #155

pbendersky opened this issue Dec 11, 2015 · 9 comments

Comments

@pbendersky
Copy link

I'm experiencing an error when adding commits to an existing Merge Requests. The error I see, however, is different to the one described in #90, so I'm opening a new issue.

When creating a new MR, Jenkins build just fine. When adding a commit, however, I get the following:

Started by GitLab push by Pablo Bendersky
[EnvInject] - Loading node environment variables.
Building on master in workspace /Users/administrator/.jenkins/jobs/quadion.citest/workspace
 > git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from 2 remote Git repositories
 > git config remote.pbendersky/citest.url [email protected]:pbendersky/citest.git # timeout=10
Fetching upstream changes from [email protected]:pbendersky/citest.git
 > git --version # timeout=10
 > git -c core.askpass=true fetch --tags --progress [email protected]:pbendersky/citest.git +refs/heads/*:refs/remotes/pbendersky/citest/*
 > git config remote.origin.url [email protected]:quadion/citest.git # timeout=10
Fetching upstream changes from [email protected]:quadion/citest.git
 > git -c core.askpass=true fetch --tags --progress [email protected]:quadion/citest.git +refs/heads/*:refs/remotes/origin/*
 > git rev-parse 71949a0e639735dabc40a84673fbed37db8632a8^{commit} # timeout=10
 > git branch -a --contains 71949a0e639735dabc40a84673fbed37db8632a8 # timeout=10
 > git rev-parse remotes/pbendersky/citest/more-tests^{commit} # timeout=10
Merging Revision 71949a0e639735dabc40a84673fbed37db8632a8 (pbendersky/citest/more-tests) to origin/more-tests, UserMergeOptions{mergeRemote='origin', mergeTarget='${gitlabTargetBranch}', mergeStrategy='default', fastForwardMode='--ff'}
 > git rev-parse origin/more-tests^{commit} # timeout=10
FATAL: Command "git rev-parse origin/more-tests^{commit}" returned status code 128:
stdout: origin/more-tests^{commit}

stderr: fatal: ambiguous argument 'origin/more-tests^{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 rev-parse origin/more-tests^{commit}" returned status code 128:
stdout: origin/more-tests^{commit}

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

The branch in my repository is called more-tests, and I have two git repositories configured, as described in the Readme.

@pbendersky
Copy link
Author

I was able to trace the error to this method:
https://github.com/jenkinsci/gitlab-plugin/blob/master/src/main/java/com/dabsquared/gitlabjenkins/GitLabWebHook.java#L394-L401

I have a project under group/project and I'm sending Merge Requests from user/project. When the hook is called on push from user/project, buildOpenMergeRequests will search for open Merge Requests on user/project, while the MRs are actually in group/project.

I'll try to provide a PR that fixes this by navigating to the forked project instead, so we can look at the existing MRs there. If anyone has a better suggestion, it's welcome, so I provide the proper fix.

@joshuajorel
Copy link

@pbendersky you can check my fork for the fix. I've also encountered this issue and I have temporarily fixed it. But I haven't updated the code so you might take a look on some of the latest changes. Have been busy so I haven't been able to code the plug-in for a while. Keep me posted.

@pbendersky
Copy link
Author

Thanks @joshuajorel, I'll take a look. Why did you not submit a PR for this? (I want to understand what's missing so I can take it from there...)

@joshuajorel
Copy link

@pbendersky I'm not quite sure what happened with the current version, but before the 1.1.29 release candidate the plug-in was working fine when it comes to pulling from a GitLab push. I've fixed that issue, but I'm not too sure about whether it was the right solution.

As for the pull request, I'm still trying to solve the buildOpenMergeRequests method. I'm still encountering some exceptions, but I'm not sure if someone made a fix for that already. I stopped midway through development since I got busy, but I'll be making some progress over the weekend since I have some free time. Feel free to ask me if you have any questions.

Thanks.

@klausbayrhammer
Copy link

Same problem here. Is there any way I can support you with the solution?

@coder-hugo
Copy link
Contributor

I can't reproduce this. Can you provide us information about your setup (used versions, config, ...)?

@pbendersky
Copy link
Author

I'm using the gitlab-plugin 1.1.29 (downloaded here and compiled) and GitLab 8.5.2.

I create a merge request, and it gets compiled. (let's say a test fails). When I add another commit to the same MR, now the plugin does not try to compile again (I think it should)

@pbendersky
Copy link
Author

Works in the latest version.

@dskrvk
Copy link

dskrvk commented Jun 7, 2017

This started affecting me since about a week ago. Jenkins v2.64, plugin v1.4.5, using gitlab.com. The first build works fine, but subsequent ones fail with the message similar to the OP's.

Edit: turned out it was my mistake. I had removed the step that merged the branches locally, thinking it's optional. Once I re-instituted that, the builds were fixed. Seems strange though that this is required for builds to work, since we already have a perfectly good branch to build. Also, Gitlab already ensures that the change can be merged cleanly.

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

No branches or pull requests

6 participants