Skip to content
This repository has been archived by the owner on Jan 25, 2022. It is now read-only.

undefined method `getQuietPeriod' for nil:NilClass when testing the /build_now/project-name webhook #32

Open
gtheraud opened this issue Jun 7, 2016 · 5 comments

Comments

@gtheraud
Copy link

gtheraud commented Jun 7, 2016

I added following webhooks for Push and Tag Push Events in gitlab :

http://jenkins.local/gitlab/build_now/my-project

my-project is a Jenkins Pipeline project. When i test the webhooks, i get the following HTTP Response :

NoMethodError at /build_now/my-project
undefined method `getQuietPeriod' for nil:NilClass
file: api.rb location: POST /build_now/:project_name line: 43

with the following stack-trace :

/var/lib/jenkins/plugins/gitlab-hook/WEB-INF/classes/models/api.rb in POST /build_now/:project_name
 project.scheduleBuild2(project.getQuietPeriod(), cause_builder.with(details), actions_builder.with(project, details))
/var/lib/jenkins/plugins/gitlab-hook/WEB-INF/classes/vendor/gems/gems/rack-protection-1.2.0/lib/rack/protection/xss_header.rb in call
 status, headers, body = @app.call(env)
/var/lib/jenkins/plugins/gitlab-hook/WEB-INF/classes/vendor/gems/gems/rack-protection-1.2.0/lib/rack/protection/path_traversal.rb in call
 app.call env
/var/lib/jenkins/plugins/gitlab-hook/WEB-INF/classes/vendor/gems/gems/rack-protection-1.2.0/lib/rack/protection/json_csrf.rb in call
 status, headers, body = app.call(env)
/var/lib/jenkins/plugins/gitlab-hook/WEB-INF/classes/vendor/gems/gems/rack-protection-1.2.0/lib/rack/protection/base.rb in call
 result or app.call(env)
/var/lib/jenkins/plugins/gitlab-hook/WEB-INF/classes/vendor/gems/gems/rack-protection-1.2.0/lib/rack/protection/xss_header.rb in call
 status, headers, body = @app.call(env)
/var/lib/jenkins/plugins/gitlab-hook/WEB-INF/classes/vendor/gems/gems/rack-1.4.1/lib/rack/nulllogger.rb in call
 @app.call(env)
/var/lib/jenkins/plugins/gitlab-hook/WEB-INF/classes/vendor/gems/gems/rack-1.4.1/lib/rack/head.rb in call
 status, headers, body = @app.call(env)
/var/lib/jenkins/plugins/gitlab-hook/WEB-INF/classes/models/root_action.rb in call
 GitlabWebHook::Api.new.call(env)
file:/var/lib/jenkins/plugins/ruby-runtime/WEB-INF/lib/jruby-rack-1.1.13.1.jar!/rack/handler/servlet.rb in call
 self.class.response.new(@app.call(create_env(servlet_env)))
@gtheraud
Copy link
Author

gtheraud commented Jun 8, 2016

This issue might be linked to #31 since my build is a Pipeline build.
I found out that there might be a bug in models/services/get_jenkins_projects.rb :

projects = Java.jenkins.model.Jenkins.instance.getAllItems(AbstractProject.java_class).map do |jenkins_project|

This won't return the pipeline jobs. When I removed AbstractProject.java_class to include pipeline jobs, i get :

undefined method 'scm' for OrgJenkinsciPluginsWorkflowJob::WorkflowJob

Unfortunately, that is how much I can do so far.

@wuzhaozhongguo
Copy link

wuzhaozhongguo commented Sep 5, 2016

I also had the same problem,my gitlab web hooks is
http://site/gitlab/build_now/projectName
jenkins 2.20

@danielmbarlow
Copy link

I had the same problem, but found a workaround. I use the same web hook as @wuzhaozhongguo, but I opened the project configuration screen in Jenkins and copied the 'Project name' field from there. After that it worked.

Before: http://<site>/gitlab/build_now/BO_Merge_Request_Build
After: http://<site>/gitlab/build_now/bo_merge_request_build

Looks like it might be a case issue.

I'm on gitlab-hook-plugin v1.4.2, Jenkins 2.7.3.

Hope that helps.

@chanxiaohui
Copy link

Is this problem solved?

@llorllale
Copy link

llorllale commented Oct 16, 2017

Having this issue on Jenkins 2.73.2., gilab-hook version 1.4.2.

@danielmbarlow 's suggestion did not work

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

No branches or pull requests

5 participants