jenkinsci / jenkins.rb

Deprecated, see https://www.jenkins.io/jep/7
394 stars 83 forks source link

Broken Jenkins::Model::Listener #107

Closed javiplx closed 9 years ago

javiplx commented 9 years ago

Im using jenkins-plugin-runtime 0.2.3 with ruby-runtime 0.12, and it seems that the Listener class is broken. It seems that the class tries to use the native ruby logger object, but Logger get somewhere masked with the java Logger class. If I comment out

@level = Logger::DEBUG

on Listener initialize method, everything seems to works fine, although that's probably only because I never actually used that listener object.

I've discovered this when trying to implement a Jenkins notifier in ruby, and I've seen that other ruby notifiers work, although no one of them is packaged with 0.2.3+0.12 but with much earlier versions.

When prebuild method is executed I get this:

> git rev-list 495066ae2265f6f56255a140c45c5815655c80e0 # timeout=10
ERROR: uninitialized constant Java::JavaUtilLogging::Logger::DEBUG (NameError)org/jruby/RubyModule.java:2677:in `const_missing'
/var/lib/jenkins/plugins/gitlab-hook/WEB-INF/classes/vendor/gems/gems/jenkins-plugin-runtime-0.2.3/lib/jenkins/model/listener.rb:15:in `initialize'
/var/lib/jenkins/plugins/gitlab-hook/WEB-INF/classes/vendor/gems/gems/jenkins-plugin-runtime-0.2.3/lib/jenkins/plugin/proxies.rb:58:in `import'
/var/lib/jenkins/plugins/gitlab-hook/WEB-INF/classes/vendor/gems/gems/jenkins-plugin-runtime-0.2.3/lib/jenkins/plugin.rb:166:in `import'
/var/lib/jenkins/plugins/gitlab-hook/WEB-INF/classes/vendor/gems/gems/jenkins-plugin-runtime-0.2.3/lib/jenkins/plugin/proxy.rb:84:in `import'
/var/lib/jenkins/plugins/gitlab-hook/WEB-INF/classes/vendor/gems/gems/jenkins-plugin-runtime-0.2.3/lib/jenkins/tasks/build_step_proxy.rb:8:in `prebuild'
/var/lib/jenkins/plugins/gitlab-hook/WEB-INF/classes/vendor/gems/gems/jenkins-plugin-runtime-0.2.3/lib/jenkins/tasks/build_step_proxy.rb:22:in `boolean_result'
/var/lib/jenkins/plugins/gitlab-hook/WEB-INF/classes/vendor/gems/gems/jenkins-plugin-runtime-0.2.3/lib/jenkins/tasks/build_step_proxy.rb:7:in `prebuild'
javiplx commented 9 years ago

Finally, it was unrelated to jenkins.rb stuff. There was a few java_import Java.java.util.logging.Logger statements on toplevel scope of some ruby files for the plugin I was working on, and they were the ones masking the ruby Logger class. Once I've encapsulated them within their proper modules/classes, the problem has disappeared.