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

Jenkins requests from Gitlab the commit status of its merge commit #325

Closed
telisior opened this issue May 18, 2016 · 5 comments
Closed

Jenkins requests from Gitlab the commit status of its merge commit #325

telisior opened this issue May 18, 2016 · 5 comments

Comments

@telisior
Copy link

Hello.
In my setup I use:

  • Gitlab plugin v1.2.2
  • Gitlab v8.7.5
  • Jenkins v2.3

In some cases, building a Merge Request fails before building with the following log on Jenkins:

Checking out Revision 8bb5e8e5d70d4da1316366f11abb01ea87841f46 (origin/master)
 > git config core.sparsecheckout # timeout=10
 > git checkout -f 8bb5e8e5d70d4da1316366f11abb01ea87841f46
 > git rev-list 1b20d154911b66eb83e077f1274e25795b62d0dc # timeout=10
FATAL: null
java.lang.NullPointerException
    at org.jboss.resteasy.util.ReadFromStream.readFromStream(ReadFromStream.java:30)
    at org.jboss.resteasy.client.jaxrs.internal.ClientResponse.bufferEntity(ClientResponse.java:307)
    at org.jboss.resteasy.client.jaxrs.internal.proxy.extractors.DefaultEntityExtractorFactory$3.extractEntity(DefaultEntityExtractorFactory.java:48)
    at org.jboss.resteasy.client.jaxrs.internal.proxy.ClientInvoker.invoke(ClientInvoker.java:104)
    at org.jboss.resteasy.client.jaxrs.internal.proxy.ClientProxy.invoke(ClientProxy.java:64)
    at com.sun.proxy.$Proxy91.headCommit(Unknown Source)
    at com.dabsquared.gitlabjenkins.util.CommitStatusUpdater.existsCommit(CommitStatusUpdater.java:72)
    at com.dabsquared.gitlabjenkins.util.CommitStatusUpdater.updateCommitStatus(CommitStatusUpdater.java:37)
    at com.dabsquared.gitlabjenkins.publisher.GitLabCommitStatusPublisher.prebuild(GitLabCommitStatusPublisher.java:33)
    at hudson.model.AbstractBuild$AbstractBuildExecution.preBuild(AbstractBuild.java:837)
    at hudson.model.AbstractBuild$AbstractBuildExecution.preBuild(AbstractBuild.java:832)
    at hudson.model.Build$BuildExecution.doRun(Build.java:144)
    at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:534)
    at hudson.model.Run.execute(Run.java:1738)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
    at hudson.model.ResourceController.execute(ResourceController.java:98)
    at hudson.model.Executor.run(Executor.java:410)

Sending e-mails to: XXXX

ERROR: Build step failed with exception
java.lang.NullPointerException
    at org.jboss.resteasy.util.ReadFromStream.readFromStream(ReadFromStream.java:30)
    at org.jboss.resteasy.client.jaxrs.internal.ClientResponse.bufferEntity(ClientResponse.java:307)
    at org.jboss.resteasy.client.jaxrs.internal.proxy.extractors.DefaultEntityExtractorFactory$3.extractEntity(DefaultEntityExtractorFactory.java:48)
    at org.jboss.resteasy.client.jaxrs.internal.proxy.ClientInvoker.invoke(ClientInvoker.java:104)
    at org.jboss.resteasy.client.jaxrs.internal.proxy.ClientProxy.invoke(ClientProxy.java:64)
    at com.sun.proxy.$Proxy91.headCommit(Unknown Source)
    at com.dabsquared.gitlabjenkins.util.CommitStatusUpdater.existsCommit(CommitStatusUpdater.java:72)
    at com.dabsquared.gitlabjenkins.util.CommitStatusUpdater.updateCommitStatus(CommitStatusUpdater.java:37)
    at com.dabsquared.gitlabjenkins.publisher.GitLabCommitStatusPublisher.perform(GitLabCommitStatusPublisher.java:45)
    at hudson.tasks.BuildStepMonitor$3.perform(BuildStepMonitor.java:45)
    at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:782)
    at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:723)
    at hudson.model.Build$BuildExecution.post2(Build.java:185)
    at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:668)
    at hudson.model.Run.execute(Run.java:1763)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
    at hudson.model.ResourceController.execute(ResourceController.java:98)
    at hudson.model.Executor.run(Executor.java:410)
Build step 'Publish build status to GitLab commit (GitLab 8.1+ required)' marked build as failure

Finished: FAILURE

When this happens I get this log from the Gitlab plugin:

May 18, 2016 7:19:31 PM FINEST com.dabsquared.gitlabjenkins.gitlab.GitLabClientBuilder

Call GitLab:
HTTP method: HEAD
URL: http://server:8090/api/v3/projects/XXXX/repository/commits/8bb5e8e5d70d4da1316366f11abb01ea87841f46
Request headers: [
Accept = [application/json],
PRIVATE-TOKEN = [****FILTERED****]
]

May 18, 2016 7:19:31 PM FINEST com.dabsquared.gitlabjenkins.gitlab.GitLabClientBuilder

Got response from GitLab:
URL: http://server:8090/api/v3/projects/XXXX/repository/commits/8bb5e8e5d70d4da1316366f11abb01ea87841f46
Status: 404 Not Found
Response headers: [
Cache-Control = [no-cache],
Connection = [keep-alive],
Content-Length = [34],
Content-Type = [application/json],
Date = [Wed, 18 May 2016 16:19:31 GMT],
Server = [nginx],
Status = [404 Not Found],
Vary = [Origin],
X-Request-Id = [cfeacc86-4ab6-4819-9165-06343a472bfd],
X-Runtime = [0.031072]
]
Response body: 

In this case, the 8bb5e8e5d70d4da1316366f11abb01ea87841f46 commit is the merge commit created by Jenkins (in the "Merge before build" step):

commit 8bb5e8e5d70d4da1316366f11abb01ea87841f46
Merge: 5fe4f16 3809e54
Author: Jenkins (on behalf of Aristotelis Iordanidis) XXXX
Date:   Wed May 18 19:19:20 2016 +0300

    Merge commit '3809e540715730ca24e34ad75449c359ee0b7f0e' into HEAD

So, Gitlab couldn't possibly know about this commit. But this commit-status request also seems to break things.
The strange thing is that I don't get this behavior in all cases, some MR's build OK (I haven't been able to figure out what makes the difference). In this case I just closed and then re-opened a pending MR to trigger the error.
The problem goes away if I don't add the post-build action "Publish build status to Gitlab commit", but then I lose a lot of the functionality.
I hadn't seen such problems in an older setup, which consisted of Jenkins v1.x, Gitlab v8.5.x and plugin v1.1.x -- unfortunately I upgraded all of them at the same time...

Any ideas, suggestions?

Thanks,

Telis

@spelcaster
Copy link

spelcaster commented May 18, 2016

@telisior, in the Repository URL field, are you using http or ssh? I had a similar issue with http, but with ssh the same does not occur.

Another thing that we saw comparing build injected variables:

  • With gitlab-plugin 1.1.27, there is no gitlabTargetRepoName and gitlabSourceRepoName is equal to 'user_space/project_id';
  • With gitlab-plugin 1.2.2, gitlabSourceRepoName and gitlabTargetRepoName is equal to the Project Name;

@spelcaster
Copy link

spelcaster commented May 18, 2016

We did the following workarounds:

  • step 1.iii:
    • URL: ${gitlabSourceRepoURL} (use ${gitlabSourceRepoSshUrl} to force ssh)
    • Name: origin1
  • step 1.iv:
    • For forked repository setups: origin1/${gitlabSourceBranch}

@telisior
Copy link
Author

telisior commented May 19, 2016

@spelcaster, thank you for you suggestions.

I'm already using the ssh URL (i.e. git@gitlab_server:group/project). I also tried with ${gitlabSourceRepoSshUrl} but I get the same error.

I'm also using the repository name (origin) instead of any variables.

@coder-hugo
Copy link
Contributor

Fixed with #311

@RuthTaylor26
Copy link

Started by user ruth taylor
[Pipeline] Start of Pipeline
[Pipeline] node
Running on Jenkins in /var/lib/jenkins/workspace/java-web-docker
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Git CheckOut)
[Pipeline] git
The recommended git tool is: NONE
No credentials specified

git rev-parse --resolve-git-dir /var/lib/jenkins/workspace/java-web-docker/.git # timeout=10
Fetching changes from the remote Git repository
git config remote.origin.url https://github.com/MithunTechnologiesDevOps/java-web-app-docker.git # timeout=10
Fetching upstream changes from https://github.com/MithunTechnologiesDevOps/java-web-app-docker.git
git --version # timeout=10
git --version # 'git version 2.34.1'
git fetch --tags --force --progress -- https://github.com/MithunTechnologiesDevOps/java-web-app-docker.git +refs/heads/:refs/remotes/origin/ # timeout=10
git rev-parse refs/remotes/origin/master^{commit} # timeout=10
Checking out Revision 56a2c3376f986db06b95b3962265d51dafa18e9f (refs/remotes/origin/master)
git config core.sparsecheckout # timeout=10
git checkout -f 56a2c3376f986db06b95b3962265d51dafa18e9f # timeout=10
git branch -a -v --no-abbrev # timeout=10
git branch -D master # timeout=10
git checkout -b master 56a2c3376f986db06b95b3962265d51dafa18e9f # timeout=10
Commit message: "Updated Code"
git rev-list --no-walk 56a2c3376f986db06b95b3962265d51dafa18e9f # timeout=10
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { ( Maven Clean Package)
[Pipeline] tool
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: No maven named Maven found
Finished: FAILURE

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

No branches or pull requests

4 participants