'gitlab/build_now' hook returns `undefined method 'getDefaultParametersValues' for #`
daaain opened this issue · comments
Hey,
I've set up a parametrised build using the guide on your blog, with Jenkins 1.522, Gitlab Hook 0.2.9 and ruby-runtime 0.12.
It doesn't really want to work so I started to debug it with requestb.in, test hooks and the POSTMan Chrome plugin.
What seems to be happening is that Jenkins returns a 500 error with the message undefined method 'getDefaultParametersValues' for #
. I figured out that it's a method which is an alias for a Jenkins Java method, but no idea how to go any further: https://github.com/manishval/gitlab-hook-plugin/blob/master/models/gitlab_project.rb#L115
Please help :)
I am having the same problem. I get:
SEVERE: undefined method `getDefaultParametersValues' for #Java::HudsonMatrix::MatrixProject:0x183c44d
I also can't figure out what I am supposed to name the parameter that is going to get the branch name for a given commit. Help!
Ah, after looking at the plugin code, I see it takes whatever parameter you use in the Branch Specifier field of your job config. It can be anything. However the code assumes that you will use the ${FOO} form of the variable, when $FOO is also valid.
I've managed to reproduce with latest plugin version and Jenkins v1.523.
Looking into it.
Don't know why that method is suddenly not available any more.
But, I found a workaround. https://github.com/elvanja/jenkins-gitlab-hook-plugin/tree/hotfix/getDefaultParametersValues_fix branch contains the new code.
Could you build the plugin and try if it works now?
I've tested it with Jenkins v1.523 and it works for me, but I'd like to verify before releasing.
Let me know how it goes, thanks!
I tried with Jenkins 1.518, and when a request comes to the plugin from the hook, the executor thread crashes. The log says:
@4000000051e9af4625c05c2c Jul 19, 2013 9:27:24 PM sun.reflect.NativeMethodAccessorImpl invoke0
@4000000051e9af4625c067e4 INFO: gitlab web hook triggered for repo url git@foo:foo/bar.git and master branch
@4000000051e9af4639545694 Jul 19, 2013 9:27:24 PM sun.reflect.NativeMethodAccessorImpl invoke0
@4000000051e9af463954624c INFO: project foo_build matches the master branch
@4000000051e9af4715952f44 Jul 19, 2013 9:27:25 PM sun.reflect.NativeMethodAccessorImpl invoke0
@4000000051e9af4715953714 INFO: foo_build scheduled for build
@4000000051e9b00014f45394 java.lang.ClassCastException: hudson.model.BooleanParameterDefinition cannot be cast to hudson.model.ParameterValue
@4000000051e9b00014f63024 at hudson.model.ParametersAction.getAssignedLabel(ParametersAction.java:127)
@4000000051e9b00014f6340c at hudson.model.Queue$Item.getAssignedLabel(Queue.java:1368)
@4000000051e9b00014f637f4 at hudson.model.Queue.makeBuildable(Queue.java:1075)
@4000000051e9b00014f66ea4 at hudson.model.Queue.maintain(Queue.java:1009)
@4000000051e9b00014f6b10c at hudson.model.Queue.pop(Queue.java:868)
@4000000051e9b00014f7b2dc at hudson.model.Executor.grabJob(Executor.java:289)
@4000000051e9b00014f7b6c4 at hudson.model.Executor.run(Executor.java:210)
I seem to have ruby-runtime 0.12. I just upgraded Jenkins to 1.523, but plugin manager doesn't show any newer version of ruby-runtime available. I can't really find much information about that plugin online anywhere. And I still get the same error when the hook is run.
Then if you could please paste the payload? Remove sensitive data of course, and some more details on how your project is configured would be helpful too, specifically the parameters, git details etc. I'll look into it then...
Payload:
INFO: with payload: {"before"=>"f4de352bd30a5d03a8b4365d9e2c5d62fb6fed40", "after"=>"bbde08b5a808c9258882db2bb82420e746df368e", "ref"=>"refs/heads/master", "user_id"=>43, "user_name"=>"Owen Mehegan", "repository"=>{"name"=>"bar_v3", "url"=>"git@gitlab.foo.com:foo/bar_v3.git", "description"=>"thing bar UI 2.0", "homepage"=>"http://gitlab.foo.com/foo/bar_v3"}, "commits"=>[{"id"=>"1ec213e86461b7668e932994d2970966bc69ad4a", "message"=>"Procfile to use 1291 for console and fix test env", "timestamp"=>"2013-07-16T23:01:40+00:00", "url"=>"http://gitlab.foo.com/foo/bar_v3/commit/1ec213e86461b7668e932994d2970966bc69ad4a", "author"=>{"name"=>"Soo Hwan Park", "email"=>"spark@foo.com"}}, {"id"=>"eba8dc84dc4fef094c50dbbc95579475712a36ac", "message"=>"bundle exec to fix rake issues", "timestamp"=>"2013-07-17T00:19:08+00:00", "url"=>"http://gitlab.foo.com/foo/bar_v3/commit/eba8dc84dc4fef094c50dbbc95579475712a36ac", "author"=>{"name"=>"Patrick Davis", "email"=>"pdavis@foo.com"}}, {"id"=>"15a84f983f39c8563fa95b3e0c124f15978f2c87", "message"=>"Merge branch 'master' into regression-tests\n\nConflicts:\n\tconfig/admin_test3.yml\n\tconfig/admin_test4.yml", "timestamp"=>"2013-07-17T00:27:34+00:00", "url"=>"http://gitlab.foo.com/foo/bar_v3/commit/15a84f983f39c8563fa95b3e0c124f15978f2c87", "author"=>{"name"=>"Soo Hwan Park", "email"=>"spark@foo.com"}}, {"id"=>"c1712538deeafc5b6067a1ffbf9e5395e2f82541", "message"=>"updated logo back to foo", "timestamp"=>"2013-07-18T19:53:04+00:00", "url"=>"http://gitlab.foo.com/foo/bar_v3/commit/c1712538deeafc5b6067a1ffbf9e5395e2f82541", "author"=>{"name"=>"Patrick Davis", "email"=>"pdavis@foo.com"}}, {"id"=>"9fb1d6dacf0a04a83be88d96e7c874b41af46260", "message"=>"changed release notes to use markdown format so it's easier to update them.\n\nAdded /release_notes/ endpoint that converts and displays them as html.", "timestamp"=>"2013-07-18T23:50:38+00:00", "url"=>"http://gitlab.foo.com/foo/bar_v3/commit/9fb1d6dacf0a04a83be88d96e7c874b41af46260", "author"=>{"name"=>"Jens Schmidt", "email"=>"jens@foo.com"}}, {"id"=>"5fc3d09fa9724eb7c973c19ef8b2e8753d433c35", "message"=>"Merge branch 'better_release_notes' of /home/git/repositories/foo/bar_v3", "timestamp"=>"2013-07-18T23:52:39+00:00", "url"=>"http://gitlab.foo.com/foo/bar_v3/commit/5fc3d09fa9724eb7c973c19ef8b2e8753d433c35", "author"=>{"name"=>"Jens Schmidt", "email"=>"jens@foo.com"}}, {"id"=>"56cce741e042bd23e201c5b5446055cd9dca2ddd", "message"=>"Squashed commit of the following:\n\n Fixed some exceptions when going between AR and LI Editing controllers\n\nPT: https://www.pivotaltracker.com/story/show/53584985\nCR: http://gitlab.foo.com/foo/bar_v3/merge_requests/322", "timestamp"=>"2013-07-19T00:20:07+00:00", "url"=>"http://gitlab.foo.com/foo/bar_v3/commit/56cce741e042bd23e201c5b5446055cd9dca2ddd", "author"=>{"name"=>"Colin Zhu", "email"=>"czhu@foo.com"}}, {"id"=>"8c7bcdb1e3f229943a64a8aec57b426ed90589c1", "message"=>"remove campaign status panel dropdown (was not functional)", "timestamp"=>"2013-07-19T16:27:43+00:00", "url"=>"http://gitlab.foo.com/foo/bar_v3/commit/8c7bcdb1e3f229943a64a8aec57b426ed90589c1", "author"=>{"name"=>"Jens Schmidt", "email"=>"jens@foo.com"}}, {"id"=>"5aa527d89419240b65dcba25b2029397ae3c9b65", "message"=>"Merge branch 'master' of gitlab.foo.com:foo/bar_v3", "timestamp"=>"2013-07-19T18:33:28+00:00", "url"=>"http://gitlab.foo.com/foo/bar_v3/commit/5aa527d89419240b65dcba25b2029397ae3c9b65", "author"=>{"name"=>"Colin Zhu", "email"=>"czhu@foo.com"}}, {"id"=>"bbde08b5a808c9258882db2bb82420e746df368e", "message"=>"Squashed commit of the following:\n\n Saving Static Bundles now only saves selected site placements from\n the grid\n\n Fixed a bug where BundleMap was not being updated after saving new\n bundles\n\nPT: https://www.pivotaltracker.com/story/show/53488973\nPT: https://www.pivotaltracker.com/story/show/53644475\nCR: http://gitlab.foo.com/foo/bar_v3/merge_requests/284", "timestamp"=>"2013-07-19T18:35:09+00:00", "url"=>"http://gitlab.foo.com/foo/bar_v3/commit/bbde08b5a808c9258882db2bb82420e746df368e", "author"=>{"name"=>"Colin Zhu", "email"=>"czhu@foo.com"}}], "total_commits_count"=>10}
The build is a matrix job (sometimes they seem to do things differently from stand-alone jobs). It has a parameter named 'branch' with a default of master. Our repo URL is set to e.g. git@gitlab.foo.com:foo/foo_v3.git. Branch specifier is ${branch} and also under advanced we have 'Checkout/merge to local branch' set to ${branch} - this is how we have always done manual builds of repo branches from the Jenkins UI.
Let me know if you need any more information.
That'll do for now. Never used matrix jobs, so I might need help, I'll ask if I hit a wall. Thanks.
OK guys, did some testing again. Used regular and matrix project (multiple configuration, unless you are talking about some other kind?) configuration too. All seems to be working. I am testing with Jenkins v1.523, Git plugin v1.4.0 and latest Gitlab hook plugin. I've also used a payload exactly like the one above, with just gitlab project url changed to match my setup.
All the Jenkins projects required to execute have been triggered for build. Essentially, I can't repeat this last issue.
I've released this latest fix as a new version v0.2.10. If you don't see it in your Jenkins instances just yet, you can download from http://repo.jenkins-ci.org/releases/org/jenkins-ci/ruby-plugins/gitlab-hook/0.2.10/ and just deploy manually.
I'd appreciate if you could test with this version and let me know how it goes.
@omehegan, if you still have issues, maybe you can try the Git notify commit trick directly. https://wiki.jenkins-ci.org/display/JENKINS/Git+Plugin#GitPlugin-Pushnotificationfromrepository has all the details. And the hook is not a problem to setup in Gitlab either. Also, if you are still experiencing issues, maybe you could create a regular Jenkins project and see if the problem occurs for it as well?
Sorry for the silence, I just grabbed the latest plugin via normal Jenkins plugin update and triggering a test hook worked, yay :) I'm pretty sure that means a normal push will also trigger it, will report back if it doesn't.
Thanks a lot for the fix, really appreciated! 👍
With the latest build, I still get the thread crash I described before. The build goes into the queue, but once it goes to actually start the job executor thread dies. I feel like I must be doing something wrong but I don't understand what. I'm using the same versions of everything as you are, except Jenkins 1.523.
@elvanja It seems like the crash is related to Jenkins trying to figure out where to run the job. My matrix/multiple configuration jobs run on several slaves, which are selected by label in the Configuration Matrix part of the job configuration. This works fine when we run the job through the Jenkins UI or with a direct GET request on the job build URL, and it's the normal way of doing matrix builds across slaves. Not sure why the gitlab plugin trigger causes it to crash.
Either that or it's just a general problem with accessing or dealing with the parameters of the build. It seems weird that it's trying to cast hudson.model.BooleanParameterDefinition cannot to hudson.model.ParameterValue.
I figured out what is causing the crash. If I have ANY other parameter associated with my job, in addition to the string parameter where the branch name is passed in, I get this crash. That seems like a bug.
It works! Hooray! We will do some more testing and file separate issues if any are found. Thank you!
Excellent!! OK, I am closing this one.
If anything else is at fault, please file a new issue.
Thanks again!