Gitlab-plugin: NullPointerException on GitLab MR hook

Created on 17 Jan 2019  路  9Comments  路  Source: jenkinsci/gitlab-plugin

Before submitting an issue I have first:

(if you have performed all the above, remove the paragraph and continue describing the issue with template below)

Issue

Context

  • Gitlab plugin version: 1.5.11
  • Gitlab version: 11.7.0-rc5-ee
  • Jenkins version: 2.150.1
  • Job type: Pipeline

Logs & Traces

Here's the strack trace displayed on Gitlab as a response to the hook:

java.lang.NullPointerException
    at com.dabsquared.gitlabjenkins.trigger.filter.BranchFilterFactory.newBranchFilter(BranchFilterFactory.java:15)
    at com.dabsquared.gitlabjenkins.GitLabPushTrigger.initializeBranchFilter(GitLabPushTrigger.java:492)
    at com.dabsquared.gitlabjenkins.GitLabPushTrigger.onPost(GitLabPushTrigger.java:448)
    at com.dabsquared.gitlabjenkins.webhook.build.MergeRequestBuildAction$1.performOnPost(MergeRequestBuildAction.java:78)
    at com.dabsquared.gitlabjenkins.webhook.build.BuildWebHookAction$TriggerNotifier.run(BuildWebHookAction.java:54)
    at hudson.security.ACL.impersonate(ACL.java:273)
    at com.dabsquared.gitlabjenkins.webhook.build.MergeRequestBuildAction.execute(MergeRequestBuildAction.java:75)
    at com.dabsquared.gitlabjenkins.webhook.build.BuildWebHookAction.execute(BuildWebHookAction.java:31)
    at com.dabsquared.gitlabjenkins.webhook.GitLabWebHook.getDynamic(GitLabWebHook.java:44)
    at java.lang.invoke.MethodHandle.invokeWithArguments(Unknown Source)
    at org.kohsuke.stapler.Function$MethodFunction.invoke(Function.java:396)
    at org.kohsuke.stapler.Function$InstanceFunction.invoke(Function.java:408)
    at org.kohsuke.stapler.Function.bindAndInvoke(Function.java:212)
    at org.kohsuke.stapler.MetaClass$9.dispatch(MetaClass.java:456)
    at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:739)
Caused: javax.servlet.ServletException
    at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:789)
    at org.kohsuke.stapler.Stapler.invoke(Stapler.java:870)
    at org.kohsuke.stapler.MetaClass$9.dispatch(MetaClass.java:458)
    at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:739)
    at org.kohsuke.stapler.Stapler.invoke(Stapler.java:870)
    at org.kohsuke.stapler.Stapler.invoke(Stapler.java:668)
    at org.kohsuke.stapler.Stapler.service(Stapler.java:238)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
    at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:865)
    at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1655)
    at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:154)
    at org.jenkinsci.plugins.ssegateway.Endpoint$SSEListenChannelFilter.doFilter(Endpoint.java:243)
    at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:151)
    at jenkins.telemetry.impl.UserLanguages$AcceptLanguageFilter.doFilter(UserLanguages.java:128)
    at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:151)
    at hudson.util.PluginServletFilter.doFilter(PluginServletFilter.java:157)
    at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1642)
    at com.dabsquared.gitlabjenkins.webhook.GitLabWebHook$GitlabWebHookCrumbExclusion.process(GitLabWebHook.java:53)
    at hudson.security.csrf.CrumbFilter.doFilter(CrumbFilter.java:73)
    at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1642)
    at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:84)
    at hudson.security.ChainedServletFilter.doFilter(ChainedServletFilter.java:90)
    at hudson.security.HudsonFilter.doFilter(HudsonFilter.java:171)
    at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1642)
    at org.kohsuke.stapler.compression.CompressionFilter.doFilter(CompressionFilter.java:49)
    at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1642)
    at hudson.util.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:82)
    at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1642)
    at org.kohsuke.stapler.DiagnosticThreadNameFilter.doFilter(DiagnosticThreadNameFilter.java:30)
    at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1642)
    at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:533)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:146)
    at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:524)
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
    at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:257)
    at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1595)
    at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:255)
    at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1340)
    at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:203)
    at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:473)
    at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1564)
    at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:201)
    at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1242)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:144)
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
    at org.eclipse.jetty.server.Server.handle(Server.java:503)
    at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:364)
    at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:260)
    at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:305)
    at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:103)
    at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:118)
    at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:333)
    at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:310)
    at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:168)
    at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:126)
    at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:366)
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:765)
    at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:683)
    at java.lang.Thread.run(Unknown Source)

Here's request body as displayed on Gitlab:

{
  "object_kind": "merge_request",
  "event_type": "merge_request",
  "user": {
    "name": "Max Yankov",
    "username": "my_username",
    "avatar_url": "https://secure.gravatar.com/avatar/756ce65e9666c2657e4893231f4665ae?s=80&d=identicon"
  },
  "project": {
    "id": 8366433,
    "name": "project_name",
    "description": "",
    "web_url": "https://gitlab.com/org_name/project_name",
    "avatar_url": null,
    "git_ssh_url": "[email protected]:org_name/project_name.git",
    "git_http_url": "https://gitlab.com/org_name/project_name.git",
    "namespace": "org_name",
    "visibility_level": 0,
    "path_with_namespace": "org_name/project_name",
    "default_branch": "master",
    "ci_config_path": null,
    "homepage": "https://gitlab.com/org_name/project_name",
    "url": "[email protected]:org_name/project_name.git",
    "ssh_url": "[email protected]:org_name/project_name.git",
    "http_url": "https://gitlab.com/org_name/project_name.git"
  },
  "object_attributes": {
    "assignee_id": null,
    "author_id": 3221106,
    "created_at": "2018-12-05 17:00:18 UTC",
    "description": "",
    "head_pipeline_id": 39210945,
    "id": 20369431,
    "iid": 1,
    "last_edited_at": null,
    "last_edited_by_id": null,
    "merge_commit_sha": "be3b146d90c902c6f2ff7fafb151585db89a823e",
    "merge_error": null,
    "merge_params": {
      "force_remove_source_branch": "0"
    },
    "merge_status": "can_be_merged",
    "merge_user_id": null,
    "merge_when_pipeline_succeeds": false,
    "milestone_id": null,
    "source_branch": "buildAutomation",
    "source_project_id": 8366433,
    "state": "merged",
    "target_branch": "dev",
    "target_project_id": 8366433,
    "time_estimate": 0,
    "title": "Build automation",
    "updated_at": "2018-12-06 15:29:32 UTC",
    "updated_by_id": null,
    "url": "https://gitlab.com/org_name/project_name/merge_requests/1",
    "source": {
      "id": 8366433,
      "name": "project_name",
      "description": "",
      "web_url": "https://gitlab.com/org_name/project_name",
      "avatar_url": null,
      "git_ssh_url": "[email protected]:org_name/project_name.git",
      "git_http_url": "https://gitlab.com/org_name/project_name.git",
      "namespace": "org_name",
      "visibility_level": 0,
      "path_with_namespace": "org_name/project_name",
      "default_branch": "master",
      "ci_config_path": null,
      "homepage": "https://gitlab.com/org_name/project_name",
      "url": "[email protected]:org_name/project_name.git",
      "ssh_url": "[email protected]:org_name/project_name.git",
      "http_url": "https://gitlab.com/org_name/project_name.git"
    },
    "target": {
      "id": 8366433,
      "name": "project_name",
      "description": "",
      "web_url": "https://gitlab.com/org_name/project_name",
      "avatar_url": null,
      "git_ssh_url": "[email protected]:org_name/project_name.git",
      "git_http_url": "https://gitlab.com/org_name/project_name.git",
      "namespace": "org_name",
      "visibility_level": 0,
      "path_with_namespace": "org_name/project_name",
      "default_branch": "master",
      "ci_config_path": null,
      "homepage": "https://gitlab.com/org_name/project_name",
      "url": "[email protected]:org_name/project_name.git",
      "ssh_url": "[email protected]:org_name/project_name.git",
      "http_url": "https://gitlab.com/org_name/project_name.git"
    },
    "last_commit": {
      "id": "b8c55fef073281e31e257726fbd6427ada08aa43",
      "message": "Removed empty post_build.py\n",
      "timestamp": "2018-12-06T15:29:02Z",
      "url": "https://gitlab.com/org_name/project_name/commit/b8c55fef073281e31e257726fbd6427ada08aa43",
      "author": {
        "name": "Max Yankov",
        "email": "my_username@org_name.ru"
      }
    },
    "work_in_progress": false,
    "total_time_spent": 0,
    "human_total_time_spent": null,
    "human_time_estimate": null
  },
  "labels": [

  ],
  "changes": {
    "total_time_spent": {
      "previous": null,
      "current": 0
    }
  },
  "repository": {
    "name": "project_name",
    "url": "[email protected]:org_name/project_name.git",
    "description": "",
    "homepage": "https://gitlab.com/org_name/project_name"
  }
}

Here's Gitlab Plugin log on Jenkins:

WebHook called with url: /project/project_name-pipeline-single

MergeRequest: {
  "object_kind" : "merge_request",
  "event_type" : "merge_request",
  "user" : {
    "name" : "Max Yankov",
    "username" : "my_username",
    "avatar_url" : "https://secure.gravatar.com/avatar/756ce65e9666c2657e4893231f4665ae?s=80&d=identicon"
  },
  "project" : {
    "id" : 8366433,
    "name" : "project_name",
    "description" : "",
    "web_url" : "https://gitlab.com/org_name/project_name",
    "avatar_url" : null,
    "git_ssh_url" : "[email protected]:org_name/project_name.git",
    "git_http_url" : "https://gitlab.com/org_name/project_name.git",
    "namespace" : "org_name",
    "visibility_level" : 0,
    "path_with_namespace" : "org_name/project_name",
    "default_branch" : "master",
    "ci_config_path" : null,
    "homepage" : "https://gitlab.com/org_name/project_name",
    "url" : "[email protected]:org_name/project_name.git",
    "ssh_url" : "[email protected]:org_name/project_name.git",
    "http_url" : "https://gitlab.com/org_name/project_name.git"
  },
  "object_attributes" : {
    "assignee_id" : null,
    "author_id" : 3221106,
    "created_at" : "2018-12-05T17:00:18.393Z",
    "description" : "",
    "head_pipeline_id" : 39210945,
    "id" : 20369431,
    "iid" : 1,
    "last_edited_at" : null,
    "last_edited_by_id" : null,
    "merge_commit_sha" : "be3b146d90c902c6f2ff7fafb151585db89a823e",
    "merge_error" : null,
    "merge_params" : {
      "force_remove_source_branch" : "0"
    },
    "merge_status" : "can_be_merged",
    "merge_user_id" : null,
    "merge_when_pipeline_succeeds" : false,
    "milestone_id" : null,
    "source_branch" : "buildAutomation",
    "source_project_id" : 8366433,
    "state" : "merged",
    "target_branch" : "dev",
    "target_project_id" : 8366433,
    "time_estimate" : 0,
    "title" : "Build automation",
    "updated_at" : "2018-12-06T15:29:32.701Z",
    "updated_by_id" : null,
    "url" : "https://gitlab.com/org_name/project_name/merge_requests/1",
    "source" : {
      "id" : 8366433,
      "name" : "project_name",
      "description" : "",
      "web_url" : "https://gitlab.com/org_name/project_name",
      "avatar_url" : null,
      "git_ssh_url" : "[email protected]:org_name/project_name.git",
      "git_http_url" : "https://gitlab.com/org_name/project_name.git",
      "namespace" : "org_name",
      "visibility_level" : 0,
      "path_with_namespace" : "org_name/project_name",
      "default_branch" : "master",
      "ci_config_path" : null,
      "homepage" : "https://gitlab.com/org_name/project_name",
      "url" : "[email protected]:org_name/project_name.git",
      "ssh_url" : "[email protected]:org_name/project_name.git",
      "http_url" : "https://gitlab.com/org_name/project_name.git"
    },
    "target" : {
      "id" : 8366433,
      "name" : "project_name",
      "description" : "",
      "web_url" : "https://gitlab.com/org_name/project_name",
      "avatar_url" : null,
      "git_ssh_url" : "[email protected]:org_name/project_name.git",
      "git_http_url" : "https://gitlab.com/org_name/project_name.git",
      "namespace" : "org_name",
      "visibility_level" : 0,
      "path_with_namespace" : "org_name/project_name",
      "default_branch" : "master",
      "ci_config_path" : null,
      "homepage" : "https://gitlab.com/org_name/project_name",
      "url" : "[email protected]:org_name/project_name.git",
      "ssh_url" : "[email protected]:org_name/project_name.git",
      "http_url" : "https://gitlab.com/org_name/project_name.git"
    },
    "last_commit" : {
      "id" : "b8c55fef073281e31e257726fbd6427ada08aa43",
      "message" : "Removed empty post_build.py\n",
      "timestamp" : "2018-12-06T15:29:02Z",
      "url" : "https://gitlab.com/org_name/project_name/commit/b8c55fef073281e31e257726fbd6427ada08aa43",
      "author" : {
        "name" : "Max Yankov",
        "email" : "my_username@org_name.ru"
      }
    },
    "work_in_progress" : false,
    "total_time_spent" : 0,
    "human_total_time_spent" : null,
    "human_time_estimate" : null
  },
  "labels" : [ ],
  "changes" : {
    "total_time_spent" : {
      "previous" : null,
      "current" : 0
    }
  },
  "repository" : {
    "name" : "project_name",
    "url" : "[email protected]:org_name/project_name.git",
    "description" : "",
    "homepage" : "https://gitlab.com/org_name/project_name"
  }
}

Problem description

Steps to reproduce:

  1. Create Jenkinsfile with the following trigger section:
    triggers {
        gitlab(
            secretToken: '(secret)',
            triggerOnMergeRequest: true, 
            pendingBuildName: 'apk_checks',
            cancelPendingBuildsOnUpdate: true,

        )
    }
  1. Set up Gitlab integration:

integrations settings org_name _ project_name gitlab - google chrome 2019-01-17 13 28 56

  1. Push new commit to existing merge request

  2. Press "Test/Merge Request Events"

Expected result:

Jenkins returns code 200 and launches build.

Actual result:

Jenkins returns code 500 with a stacktrace and doesn't launch the build.

Most helpful comment

I found a workaround:

    triggers {
        gitlab(
            secretToken: '(secret)',
            triggerOnMergeRequest: true, 
            pendingBuildName: 'apk_checks',
            cancelPendingBuildsOnUpdate: true,
            branchFilterType: 'All'   
        )
    }

Adding explicit branchFilterType: 'All' solved the NullPointerException. Still curious as to what caused it.

All 9 comments

After reading the source code in question, NullPointerException at BranchFilterFactory.java:15 seems highly improbable, because there's a null check right befor it:

    if(config == null) // here's the null check
        return new AllBranchesFilter();

        switch (config.getType()) { // here's NullPointerException

I'm buffled that this can happen at all. Judging by the blame on the source file it seems as if this bug can be related to bug #454 since PR #759 added null-check.

I found a workaround:

    triggers {
        gitlab(
            secretToken: '(secret)',
            triggerOnMergeRequest: true, 
            pendingBuildName: 'apk_checks',
            cancelPendingBuildsOnUpdate: true,
            branchFilterType: 'All'   
        )
    }

Adding explicit branchFilterType: 'All' solved the NullPointerException. Still curious as to what caused it.

I have the same problem. The branchFilterType didn't solve the problem.

  • Gitlab plugin version: 1.5.11
  • Gitlab version: 11.5
  • Jenkins version: 2.138.2
  • Job type: Pipeline
    triggers {
        gitlab (
                triggerOnPush: false,
                triggerOnMergeRequest: true,
                triggerOpenMergeRequestOnPush: 'source',
                triggerOnNoteRequest: true,
                noteRegex: '(?i)(Jenkins).*(build)(?-i)',
                branchFilterType: 'All',
                secretToken: 'xxx'
        )
    }

update:
I reorder the variables and regenerated the token and it started working...

I'm experiencing a similar issue. The null check protects against config being null but it's my understanding that the switch() statement will throw a NPE if the value it's provided is null.

Would something like

    if(config == null || config.getType() == null) // here's the null check
        return new AllBranchesFilter();

        switch (config.getType()) { // no more NullPointerException

be an acceptable fix? I'm unable to make this patch and test it myself.

.

Before submitting an issue I have first:

_(if you have performed all the above, remove the paragraph and continue describing the issue with template below)_

Issue

Context

  • Gitlab plugin version: 1.5.11
  • Gitlab version: 11.7.0-rc5-ee
  • Jenkins version: 2.150.1
  • Job type: Pipeline

Logs & Traces

Here's the strack trace displayed on Gitlab as a response to the hook:

java.lang.NullPointerException
  at com.dabsquared.gitlabjenkins.trigger.filter.BranchFilterFactory.newBranchFilter(BranchFilterFactory.java:15)
  at com.dabsquared.gitlabjenkins.GitLabPushTrigger.initializeBranchFilter(GitLabPushTrigger.java:492)
  at com.dabsquared.gitlabjenkins.GitLabPushTrigger.onPost(GitLabPushTrigger.java:448)
  at com.dabsquared.gitlabjenkins.webhook.build.MergeRequestBuildAction$1.performOnPost(MergeRequestBuildAction.java:78)
  at com.dabsquared.gitlabjenkins.webhook.build.BuildWebHookAction$TriggerNotifier.run(BuildWebHookAction.java:54)
  at hudson.security.ACL.impersonate(ACL.java:273)
  at com.dabsquared.gitlabjenkins.webhook.build.MergeRequestBuildAction.execute(MergeRequestBuildAction.java:75)
  at com.dabsquared.gitlabjenkins.webhook.build.BuildWebHookAction.execute(BuildWebHookAction.java:31)
  at com.dabsquared.gitlabjenkins.webhook.GitLabWebHook.getDynamic(GitLabWebHook.java:44)
  at java.lang.invoke.MethodHandle.invokeWithArguments(Unknown Source)
  at org.kohsuke.stapler.Function$MethodFunction.invoke(Function.java:396)
  at org.kohsuke.stapler.Function$InstanceFunction.invoke(Function.java:408)
  at org.kohsuke.stapler.Function.bindAndInvoke(Function.java:212)
  at org.kohsuke.stapler.MetaClass$9.dispatch(MetaClass.java:456)
  at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:739)
Caused: javax.servlet.ServletException
  at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:789)
  at org.kohsuke.stapler.Stapler.invoke(Stapler.java:870)
  at org.kohsuke.stapler.MetaClass$9.dispatch(MetaClass.java:458)
  at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:739)
  at org.kohsuke.stapler.Stapler.invoke(Stapler.java:870)
  at org.kohsuke.stapler.Stapler.invoke(Stapler.java:668)
  at org.kohsuke.stapler.Stapler.service(Stapler.java:238)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
  at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:865)
  at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1655)
  at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:154)
  at org.jenkinsci.plugins.ssegateway.Endpoint$SSEListenChannelFilter.doFilter(Endpoint.java:243)
  at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:151)
  at jenkins.telemetry.impl.UserLanguages$AcceptLanguageFilter.doFilter(UserLanguages.java:128)
  at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:151)
  at hudson.util.PluginServletFilter.doFilter(PluginServletFilter.java:157)
  at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1642)
  at com.dabsquared.gitlabjenkins.webhook.GitLabWebHook$GitlabWebHookCrumbExclusion.process(GitLabWebHook.java:53)
  at hudson.security.csrf.CrumbFilter.doFilter(CrumbFilter.java:73)
  at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1642)
  at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:84)
  at hudson.security.ChainedServletFilter.doFilter(ChainedServletFilter.java:90)
  at hudson.security.HudsonFilter.doFilter(HudsonFilter.java:171)
  at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1642)
  at org.kohsuke.stapler.compression.CompressionFilter.doFilter(CompressionFilter.java:49)
  at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1642)
  at hudson.util.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:82)
  at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1642)
  at org.kohsuke.stapler.DiagnosticThreadNameFilter.doFilter(DiagnosticThreadNameFilter.java:30)
  at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1642)
  at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:533)
  at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:146)
  at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:524)
  at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
  at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:257)
  at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1595)
  at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:255)
  at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1340)
  at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:203)
  at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:473)
  at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1564)
  at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:201)
  at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1242)
  at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:144)
  at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
  at org.eclipse.jetty.server.Server.handle(Server.java:503)
  at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:364)
  at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:260)
  at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:305)
  at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:103)
  at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:118)
  at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:333)
  at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:310)
  at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:168)
  at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:126)
  at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:366)
  at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:765)
  at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:683)
  at java.lang.Thread.run(Unknown Source)

Here's request body as displayed on Gitlab:

{
  "object_kind": "merge_request",
  "event_type": "merge_request",
  "user": {
    "name": "Max Yankov",
    "username": "my_username",
    "avatar_url": "https://secure.gravatar.com/avatar/756ce65e9666c2657e4893231f4665ae?s=80&d=identicon"
  },
  "project": {
    "id": 8366433,
    "name": "project_name",
    "description": "",
    "web_url": "https://gitlab.com/org_name/project_name",
    "avatar_url": null,
    "git_ssh_url": "[email protected]:org_name/project_name.git",
    "git_http_url": "https://gitlab.com/org_name/project_name.git",
    "namespace": "org_name",
    "visibility_level": 0,
    "path_with_namespace": "org_name/project_name",
    "default_branch": "master",
    "ci_config_path": null,
    "homepage": "https://gitlab.com/org_name/project_name",
    "url": "[email protected]:org_name/project_name.git",
    "ssh_url": "[email protected]:org_name/project_name.git",
    "http_url": "https://gitlab.com/org_name/project_name.git"
  },
  "object_attributes": {
    "assignee_id": null,
    "author_id": 3221106,
    "created_at": "2018-12-05 17:00:18 UTC",
    "description": "",
    "head_pipeline_id": 39210945,
    "id": 20369431,
    "iid": 1,
    "last_edited_at": null,
    "last_edited_by_id": null,
    "merge_commit_sha": "be3b146d90c902c6f2ff7fafb151585db89a823e",
    "merge_error": null,
    "merge_params": {
      "force_remove_source_branch": "0"
    },
    "merge_status": "can_be_merged",
    "merge_user_id": null,
    "merge_when_pipeline_succeeds": false,
    "milestone_id": null,
    "source_branch": "buildAutomation",
    "source_project_id": 8366433,
    "state": "merged",
    "target_branch": "dev",
    "target_project_id": 8366433,
    "time_estimate": 0,
    "title": "Build automation",
    "updated_at": "2018-12-06 15:29:32 UTC",
    "updated_by_id": null,
    "url": "https://gitlab.com/org_name/project_name/merge_requests/1",
    "source": {
      "id": 8366433,
      "name": "project_name",
      "description": "",
      "web_url": "https://gitlab.com/org_name/project_name",
      "avatar_url": null,
      "git_ssh_url": "[email protected]:org_name/project_name.git",
      "git_http_url": "https://gitlab.com/org_name/project_name.git",
      "namespace": "org_name",
      "visibility_level": 0,
      "path_with_namespace": "org_name/project_name",
      "default_branch": "master",
      "ci_config_path": null,
      "homepage": "https://gitlab.com/org_name/project_name",
      "url": "[email protected]:org_name/project_name.git",
      "ssh_url": "[email protected]:org_name/project_name.git",
      "http_url": "https://gitlab.com/org_name/project_name.git"
    },
    "target": {
      "id": 8366433,
      "name": "project_name",
      "description": "",
      "web_url": "https://gitlab.com/org_name/project_name",
      "avatar_url": null,
      "git_ssh_url": "[email protected]:org_name/project_name.git",
      "git_http_url": "https://gitlab.com/org_name/project_name.git",
      "namespace": "org_name",
      "visibility_level": 0,
      "path_with_namespace": "org_name/project_name",
      "default_branch": "master",
      "ci_config_path": null,
      "homepage": "https://gitlab.com/org_name/project_name",
      "url": "[email protected]:org_name/project_name.git",
      "ssh_url": "[email protected]:org_name/project_name.git",
      "http_url": "https://gitlab.com/org_name/project_name.git"
    },
    "last_commit": {
      "id": "b8c55fef073281e31e257726fbd6427ada08aa43",
      "message": "Removed empty post_build.py\n",
      "timestamp": "2018-12-06T15:29:02Z",
      "url": "https://gitlab.com/org_name/project_name/commit/b8c55fef073281e31e257726fbd6427ada08aa43",
      "author": {
        "name": "Max Yankov",
        "email": "my_username@org_name.ru"
      }
    },
    "work_in_progress": false,
    "total_time_spent": 0,
    "human_total_time_spent": null,
    "human_time_estimate": null
  },
  "labels": [

  ],
  "changes": {
    "total_time_spent": {
      "previous": null,
      "current": 0
    }
  },
  "repository": {
    "name": "project_name",
    "url": "[email protected]:org_name/project_name.git",
    "description": "",
    "homepage": "https://gitlab.com/org_name/project_name"
  }
}

Here's Gitlab Plugin log on Jenkins:

WebHook called with url: /project/project_name-pipeline-single

MergeRequest: {
  "object_kind" : "merge_request",
  "event_type" : "merge_request",
  "user" : {
    "name" : "Max Yankov",
    "username" : "my_username",
    "avatar_url" : "https://secure.gravatar.com/avatar/756ce65e9666c2657e4893231f4665ae?s=80&d=identicon"
  },
  "project" : {
    "id" : 8366433,
    "name" : "project_name",
    "description" : "",
    "web_url" : "https://gitlab.com/org_name/project_name",
    "avatar_url" : null,
    "git_ssh_url" : "[email protected]:org_name/project_name.git",
    "git_http_url" : "https://gitlab.com/org_name/project_name.git",
    "namespace" : "org_name",
    "visibility_level" : 0,
    "path_with_namespace" : "org_name/project_name",
    "default_branch" : "master",
    "ci_config_path" : null,
    "homepage" : "https://gitlab.com/org_name/project_name",
    "url" : "[email protected]:org_name/project_name.git",
    "ssh_url" : "[email protected]:org_name/project_name.git",
    "http_url" : "https://gitlab.com/org_name/project_name.git"
  },
  "object_attributes" : {
    "assignee_id" : null,
    "author_id" : 3221106,
    "created_at" : "2018-12-05T17:00:18.393Z",
    "description" : "",
    "head_pipeline_id" : 39210945,
    "id" : 20369431,
    "iid" : 1,
    "last_edited_at" : null,
    "last_edited_by_id" : null,
    "merge_commit_sha" : "be3b146d90c902c6f2ff7fafb151585db89a823e",
    "merge_error" : null,
    "merge_params" : {
      "force_remove_source_branch" : "0"
    },
    "merge_status" : "can_be_merged",
    "merge_user_id" : null,
    "merge_when_pipeline_succeeds" : false,
    "milestone_id" : null,
    "source_branch" : "buildAutomation",
    "source_project_id" : 8366433,
    "state" : "merged",
    "target_branch" : "dev",
    "target_project_id" : 8366433,
    "time_estimate" : 0,
    "title" : "Build automation",
    "updated_at" : "2018-12-06T15:29:32.701Z",
    "updated_by_id" : null,
    "url" : "https://gitlab.com/org_name/project_name/merge_requests/1",
    "source" : {
      "id" : 8366433,
      "name" : "project_name",
      "description" : "",
      "web_url" : "https://gitlab.com/org_name/project_name",
      "avatar_url" : null,
      "git_ssh_url" : "[email protected]:org_name/project_name.git",
      "git_http_url" : "https://gitlab.com/org_name/project_name.git",
      "namespace" : "org_name",
      "visibility_level" : 0,
      "path_with_namespace" : "org_name/project_name",
      "default_branch" : "master",
      "ci_config_path" : null,
      "homepage" : "https://gitlab.com/org_name/project_name",
      "url" : "[email protected]:org_name/project_name.git",
      "ssh_url" : "[email protected]:org_name/project_name.git",
      "http_url" : "https://gitlab.com/org_name/project_name.git"
    },
    "target" : {
      "id" : 8366433,
      "name" : "project_name",
      "description" : "",
      "web_url" : "https://gitlab.com/org_name/project_name",
      "avatar_url" : null,
      "git_ssh_url" : "[email protected]:org_name/project_name.git",
      "git_http_url" : "https://gitlab.com/org_name/project_name.git",
      "namespace" : "org_name",
      "visibility_level" : 0,
      "path_with_namespace" : "org_name/project_name",
      "default_branch" : "master",
      "ci_config_path" : null,
      "homepage" : "https://gitlab.com/org_name/project_name",
      "url" : "[email protected]:org_name/project_name.git",
      "ssh_url" : "[email protected]:org_name/project_name.git",
      "http_url" : "https://gitlab.com/org_name/project_name.git"
    },
    "last_commit" : {
      "id" : "b8c55fef073281e31e257726fbd6427ada08aa43",
      "message" : "Removed empty post_build.py\n",
      "timestamp" : "2018-12-06T15:29:02Z",
      "url" : "https://gitlab.com/org_name/project_name/commit/b8c55fef073281e31e257726fbd6427ada08aa43",
      "author" : {
        "name" : "Max Yankov",
        "email" : "my_username@org_name.ru"
      }
    },
    "work_in_progress" : false,
    "total_time_spent" : 0,
    "human_total_time_spent" : null,
    "human_time_estimate" : null
  },
  "labels" : [ ],
  "changes" : {
    "total_time_spent" : {
      "previous" : null,
      "current" : 0
    }
  },
  "repository" : {
    "name" : "project_name",
    "url" : "[email protected]:org_name/project_name.git",
    "description" : "",
    "homepage" : "https://gitlab.com/org_name/project_name"
  }
}

Problem description

Steps to reproduce:

  1. Create Jenkinsfile with the following trigger section:
    triggers {
        gitlab(
            secretToken: '(secret)',
            triggerOnMergeRequest: true, 
            pendingBuildName: 'apk_checks',
            cancelPendingBuildsOnUpdate: true,

        )
    }
  1. Set up Gitlab integration:

integrations settings org_name _ project_name gitlab - google chrome 2019-01-17 13 28 56

  1. Push new commit to existing merge request
  2. Press "Test/Merge Request Events"

Expected result:

Jenkins returns code 200 and launches build.

Actual result:

Jenkins returns code 500 with a stacktrace and doesn't launch the build.

image

I just update gitlab webook config in project, and resolve this question.
this project's config is copy from other project ,so I think this is the reason of error

I have the very same error. After each successful push, I get again 500 error. I always need to go to the job and save it again and then the push works but just one time. I have the following triggers in my pipeline job:

    triggers {
        gitlab(
            triggerOnPush: true,
            triggerOnMergeRequest: true, 
            triggerOpenMergeRequestOnPush: "never",
            triggerOnNoteRequest: true,
            noteRegex: "Jenkins please retry a build",
            skipWorkInProgressMergeRequest: true,
            ciSkip: false,
            setBuildDescription: true,
            addNoteOnMergeRequest: true,
            addCiMessage: true,
            addVoteOnMergeRequest: true,
            acceptMergeRequestOnSuccess: false,
            pendingBuildName: "Jenkins",
            cancelPendingBuildsOnUpdate: false
        )
    }

Is there any update on this? Sometimes it just stops working. Saving my Jenkins pipeline via UI begins to allow webhooks again?

EDIT: This is just for normal PUSH

This was corrected in #1015

Was this page helpful?
0 / 5 - 0 ratings