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

Hook fails on parametrized jobs

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      Given:
      1. Gitlab hooks configured and works well for few projects
      2. For each project I'd created few jobs

      All works as expected.
      Step to reproduce:
      Add one job with GIT_BRANCH parameter (in my case I have job with choice parameter. Branch to build: $GIT_BRANCH).
      Note, that this job has triggered only manually, e.g. "poll scm periodically" is not configured.

      When Jenkins gets gitlab hook I see exception:

      Aug 12, 2014 6:52:38 PM org.eclipse.jetty.util.log.JavaUtilLog info
      INFO: TypeError - cannot convert instance of class org.jruby.RubyException to class java.lang.Throwable:
              org/jruby/RubyMethod.java:130:in `call'
              /var/lib/jenkins/plugins/gitlab-hook/WEB-INF/classes/models/api.rb:53:in `process_projects'
              /var/lib/jenkins/plugins/gitlab-hook/WEB-INF/classes/models/api.rb:24:in `POST /notify_commit'
              org/jruby/RubyMethod.java:118:in `call'
              /var/lib/jenkins/plugins/gitlab-hook/WEB-INF/classes/vendor/gems/gems/sinatra-1.3.3/lib/sinatra/base.rb:1265:in `compile!'
              org/jruby/RubyProc.java:249:in `call'
              /var/lib/jenkins/plugins/gitlab-hook/WEB-INF/classes/vendor/gems/gems/sinatra-1.3.3/lib/sinatra/base.rb:835:in `route!'
              /var/lib/jenkins/plugins/gitlab-hook/WEB-INF/classes/vendor/gems/gems/sinatra-1.3.3/lib/sinatra/base.rb:851:in `route_eval'
              /var/lib/jenkins/plugins/gitlab-hook/WEB-INF/classes/vendor/gems/gems/sinatra-1.3.3/lib/sinatra/base.rb:835:in `route!'
              /var/lib/jenkins/plugins/gitlab-hook/WEB-INF/classes/vendor/gems/gems/sinatra-1.3.3/lib/sinatra/base.rb:872:in `process_route'
              org/jruby/RubyKernel.java:1174:in `catch'
              /var/lib/jenkins/plugins/gitlab-hook/WEB-INF/classes/vendor/gems/gems/sinatra-1.3.3/lib/sinatra/base.rb:870:in `process_route'
              /var/lib/jenkins/plugins/gitlab-hook/WEB-INF/classes/vendor/gems/gems/sinatra-1.3.3/lib/sinatra/base.rb:834:in `route!'
              org/jruby/RubyArray.java:1613:in `each'
              /var/lib/jenkins/plugins/gitlab-hook/WEB-INF/classes/vendor/gems/gems/sinatra-1.3.3/lib/sinatra/base.rb:833:in `route!'
              /var/lib/jenkins/plugins/gitlab-hook/WEB-INF/classes/vendor/gems/gems/sinatra-1.3.3/lib/sinatra/base.rb:936:in `dispatch!'
              /var/lib/jenkins/plugins/gitlab-hook/WEB-INF/classes/vendor/gems/gems/sinatra-1.3.3/lib/sinatra/base.rb:769:in `call!'
              /var/lib/jenkins/plugins/gitlab-hook/WEB-INF/classes/vendor/gems/gems/sinatra-1.3.3/lib/sinatra/base.rb:921:in `invoke'
              org/jruby/RubyKernel.java:1174:in `catch'
              /var/lib/jenkins/plugins/gitlab-hook/WEB-INF/classes/vendor/gems/gems/sinatra-1.3.3/lib/sinatra/base.rb:921:in `invoke'
              /var/lib/jenkins/plugins/gitlab-hook/WEB-INF/classes/vendor/gems/gems/sinatra-1.3.3/lib/sinatra/base.rb:769:in `call!'
              /var/lib/jenkins/plugins/gitlab-hook/WEB-INF/classes/vendor/gems/gems/sinatra-1.3.3/lib/sinatra/base.rb:755:in `call'
              /var/lib/jenkins/plugins/gitlab-hook/WEB-INF/classes/vendor/gems/gems/rack-protection-1.2.0/lib/rack/protection/xss_header.rb:22:in `call'
              /var/lib/jenkins/plugins/gitlab-hook/WEB-INF/classes/vendor/gems/gems/rack-protection-1.2.0/lib/rack/protection/path_traversal.rb:16:in `call'
              /var/lib/jenkins/plugins/gitlab-hook/WEB-INF/classes/vendor/gems/gems/rack-protection-1.2.0/lib/rack/protection/json_csrf.rb:17:in `call'
              /var/lib/jenkins/plugins/gitlab-hook/WEB-INF/classes/vendor/gems/gems/rack-protection-1.2.0/lib/rack/protection/base.rb:47:in `call'
              /var/lib/jenkins/plugins/gitlab-hook/WEB-INF/classes/vendor/gems/gems/rack-protection-1.2.0/lib/rack/protection/xss_header.rb:22:in `call'
              /var/lib/jenkins/plugins/gitlab-hook/WEB-INF/classes/vendor/gems/gems/rack-1.4.1/lib/rack/nulllogger.rb:9:in `call'
              /var/lib/jenkins/plugins/gitlab-hook/WEB-INF/classes/vendor/gems/gems/rack-1.4.1/lib/rack/head.rb:9:in `call'
              /var/lib/jenkins/plugins/gitlab-hook/WEB-INF/classes/vendor/gems/gems/sinatra-1.3.3/lib/sinatra/showexceptions.rb:21:in `call'
              /var/lib/jenkins/plugins/gitlab-hook/WEB-INF/classes/vendor/gems/gems/sinatra-1.3.3/lib/sinatra/base.rb:99:in `call'
              /var/lib/jenkins/plugins/gitlab-hook/WEB-INF/classes/models/root_action.rb:16:in `call'
      

      Only jobs for this project (repository) aren't built anymore.
      If I disable this job, all things back to work.

        Attachments

          Activity

          Hide
          adrianbridgett Adrian Bridgett added a comment -

          FWIW I reverted the api.rb change from https://github.com/elvanja/jenkins-gitlab-hook-plugin/commit/c6913463afa312ebb8bfd93e0296998471d1791a

          and that "fixed" it for me.

          Show
          adrianbridgett Adrian Bridgett added a comment - FWIW I reverted the api.rb change from https://github.com/elvanja/jenkins-gitlab-hook-plugin/commit/c6913463afa312ebb8bfd93e0296998471d1791a and that "fixed" it for me.
          Hide
          timroes Tim Roes added a comment -

          The reset in the api.rb should actually prevent the above exception, since a Ruby Exception cannot be converted to a Java Exception (and passed to the Throwable parameter of the sever logger method).

          BUT this should not fix the actual problem. If you have a project that determines its branch from a parameter (that isn't a plain string parameter) an exception will be thrown. We currently have problem with this behavior, since we have some jobs that should be triggered automatically, and some that should be started by selecting a git tag. The git tag (which isn't a string parameter) causes the plugin to fail, so our development jobs, that should be triggered automatically will never run.

          We currently modified the plugin, by commenting the line https://github.com/jenkinsci/gitlab-hook-plugin/blob/master/models/values/project.rb#L80.

          That is not a real solution to this problem. I think the `get_branch_name_parameter` method ( https://github.com/jenkinsci/gitlab-hook-plugin/blob/master/models/values/project.rb#L46 ) should not throw an exception for not string parameters, but just log that out, and ignore that job (treat it as not matching and not causing a build for it).

          Since I am not a Ruby programmer, I don't feel able to send a pull request for that. Might anyone of you fix that?

          Thanks, Tim

          Show
          timroes Tim Roes added a comment - The reset in the api.rb should actually prevent the above exception, since a Ruby Exception cannot be converted to a Java Exception (and passed to the Throwable parameter of the sever logger method). BUT this should not fix the actual problem. If you have a project that determines its branch from a parameter (that isn't a plain string parameter) an exception will be thrown. We currently have problem with this behavior, since we have some jobs that should be triggered automatically, and some that should be started by selecting a git tag. The git tag (which isn't a string parameter) causes the plugin to fail, so our development jobs, that should be triggered automatically will never run. We currently modified the plugin, by commenting the line https://github.com/jenkinsci/gitlab-hook-plugin/blob/master/models/values/project.rb#L80 . That is not a real solution to this problem. I think the `get_branch_name_parameter` method ( https://github.com/jenkinsci/gitlab-hook-plugin/blob/master/models/values/project.rb#L46 ) should not throw an exception for not string parameters, but just log that out, and ignore that job (treat it as not matching and not causing a build for it). Since I am not a Ruby programmer, I don't feel able to send a pull request for that. Might anyone of you fix that? Thanks, Tim
          Hide
          hhyycc0418 Stayman Hou added a comment -

          Exactly same issue here.

          Show
          hhyycc0418 Stayman Hou added a comment - Exactly same issue here.
          Hide
          elvanja Vanja Radovanović added a comment -

          Hey guys, apologies for a bit late response.
          Anyway, the issue with ruby exceptions is solved now in master branch.
          There will not be a new release just yet, but you can pull that source and try it if you like.

          As for your problem with building mixed kind of projects (with branch parameter and without it), there should be no problems. Namely, the ruby exceptions issue was stopping the plugin from processing other jobs so that should no longer be a show stopper.

          The other problem you seem to have is related to GIT_BRANCH parameter which is not of a String type. The idea behind this parameter is that the plugin will fill that parameter value with branch received from Gitlab payload. If I understood, you have jobs which have GIT_BRANCH parameter defined in Source Code Management --> Branch specifier (in job definition) and the parameter is a choice parameter (with predefined values). If that is correct, I've also added a fix (in master) that will skip such projects.

          I'll close the issue here, but please feel free to open it up again (or any other) at project's Github page. Thank you!

          Show
          elvanja Vanja Radovanović added a comment - Hey guys, apologies for a bit late response. Anyway, the issue with ruby exceptions is solved now in master branch. There will not be a new release just yet, but you can pull that source and try it if you like. As for your problem with building mixed kind of projects (with branch parameter and without it), there should be no problems. Namely, the ruby exceptions issue was stopping the plugin from processing other jobs so that should no longer be a show stopper. The other problem you seem to have is related to GIT_BRANCH parameter which is not of a String type. The idea behind this parameter is that the plugin will fill that parameter value with branch received from Gitlab payload. If I understood, you have jobs which have GIT_BRANCH parameter defined in Source Code Management --> Branch specifier (in job definition) and the parameter is a choice parameter (with predefined values). If that is correct, I've also added a fix (in master) that will skip such projects. I'll close the issue here, but please feel free to open it up again (or any other) at project's Github page . Thank you!
          Hide
          stephenfinney Stephen Finney added a comment - - edited

          I've got this issue too. Any word on a new version of Jenkins with this fix included?

          Show
          stephenfinney Stephen Finney added a comment - - edited I've got this issue too. Any word on a new version of Jenkins with this fix included?
          Hide
          elvanja Vanja Radovanović added a comment -

          No definite timeline just yet. Have to close a few remaining issues.
          Hopefully in a month.

          Show
          elvanja Vanja Radovanović added a comment - No definite timeline just yet. Have to close a few remaining issues. Hopefully in a month.
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Vanja Radovanović
          Path:
          models/api.rb
          http://jenkins-ci.org/commit/gitlab-hook-plugin/81e2725fc901863fe3ed206f3ccda82d4e83329d
          Log:
          Changelog:

          • logging request details nicely, including payload
          • error handling fix, exceptions converted to java RuntimeException, related to JENKINS-24232
          • on error displaying stack trace as well
          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Vanja Radovanović Path: models/api.rb http://jenkins-ci.org/commit/gitlab-hook-plugin/81e2725fc901863fe3ed206f3ccda82d4e83329d Log: Changelog: logging request details nicely, including payload error handling fix, exceptions converted to java RuntimeException, related to JENKINS-24232 on error displaying stack trace as well
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Vanja Radovanović
          Path:
          models/values/project.rb
          spec/values/project_spec.rb
          http://jenkins-ci.org/commit/gitlab-hook-plugin/dc1248591d4e51d37d8fd1836a55e93af4c62c53
          Log:
          fix for branch specifier that is not of String type
          now just skipping such projects instead of raising exception (JENKINS-24232)

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Vanja Radovanović Path: models/values/project.rb spec/values/project_spec.rb http://jenkins-ci.org/commit/gitlab-hook-plugin/dc1248591d4e51d37d8fd1836a55e93af4c62c53 Log: fix for branch specifier that is not of String type now just skipping such projects instead of raising exception ( JENKINS-24232 )

            People

            • Assignee:
              elvanja Vanja Radovanović
              Reporter:
              jsirex jsirex
            • Votes:
              1 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: