Encountering issues while using float types in a pipeline plugin

29 views
Skip to first unread message

Andrius Ordojan

unread,
Jan 24, 2017, 9:06:13 AM1/24/17
to Jenkins Developers
I'm trying to add pipeline support to an existing plugin. I'm finding some strange behaviours when dealing with floats.

I implemented SimpleBuildStep in my publisher and that seems to be working as expected. For now I just tried using the snippet generator to see if everything evaluates correctly.

it generates codesonar conditions: [], credentialId: '', hubAddress: '10.10.10.10', projectName: '${JOB_NAME}', protocol: 'http'



When I added a condition I get this



codesonar conditions: [warningCountIncreaseNewOnly(percentage: <object of type java.lang.Float>)], credentialId: '', hubAddress: '10.10.10.10', projectName: '${JOB_NAME}', protocol: 'http'

Instead of a number, I get <object of type java.lang.Float>. This doesn't happen with integers.

I noticed an exception in the terminal as well

Jan 23, 2017 3:39:40 PM org.jenkinsci.plugins.structs.describable.DescribableModel uninstantiate2
WARNING: Cannot create control version of class org.jenkinsci.plugins.codesonar.conditions.NewWarningsIncreasedByPercentageCondition using {}
java.lang.UnsupportedOperationException: not yet handling @DataBoundConstructor default value of float; pass an explicit value for percentage
        at org.jenkinsci.plugins.structs.describable.DescribableModel.buildArguments(DescribableModel.java:317)
        at org.jenkinsci.plugins.structs.describable.DescribableModel.instantiate(DescribableModel.java:257)
        at org.jenkinsci.plugins.structs.describable.DescribableModel.uninstantiate2(DescribableModel.java:536)
        at org.jenkinsci.plugins.structs.describable.DescribableModel.uninstantiate2_(DescribableModel.java:612)
        at org.jenkinsci.plugins.structs.describable.DescribableParameter.uncoerce(DescribableParameter.java:193)
        at org.jenkinsci.plugins.structs.describable.DescribableParameter.uncoerce(DescribableParameter.java:187)
        at org.jenkinsci.plugins.structs.describable.DescribableParameter.inspect(DescribableParameter.java:141)
        at org.jenkinsci.plugins.structs.describable.DescribableModel.uninstantiate2(DescribableModel.java:522)
        at org.jenkinsci.plugins.structs.describable.DescribableModel.uninstantiate2_(DescribableModel.java:612)
        at org.jenkinsci.plugins.structs.describable.DescribableParameter.uncoerce(DescribableParameter.java:193)
        at org.jenkinsci.plugins.structs.describable.DescribableParameter.inspect(DescribableParameter.java:141)
        at org.jenkinsci.plugins.structs.describable.DescribableModel.uninstantiate2(DescribableModel.java:522)
        at org.jenkinsci.plugins.structs.describable.DescribableModel.uninstantiate2_(DescribableModel.java:612)
        at org.jenkinsci.plugins.workflow.steps.StepDescriptor.uninstantiate(StepDescriptor.java:239)
        at org.jenkinsci.plugins.workflow.cps.Snippetizer.object2Groovy(Snippetizer.java:124)
        at org.jenkinsci.plugins.workflow.cps.Snippetizer.step2Groovy(Snippetizer.java:79)
        at org.jenkinsci.plugins.workflow.cps.Snippetizer.doGenerateSnippet(Snippetizer.java:495)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:497)
        at org.kohsuke.stapler.Function$InstanceFunction.invoke(Function.java:298)
        at org.kohsuke.stapler.Function.bindAndInvoke(Function.java:161)
        at org.kohsuke.stapler.Function.bindAndInvokeAndServeResponse(Function.java:96)
        at org.kohsuke.stapler.MetaClass$1.doDispatch(MetaClass.java:121)
        at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:53)
        at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:746)
        at org.kohsuke.stapler.Stapler.invoke(Stapler.java:876)
        at org.kohsuke.stapler.MetaClass$13.dispatch(MetaClass.java:411)
        at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:746)
        at org.kohsuke.stapler.Stapler.invoke(Stapler.java:876)
        at org.kohsuke.stapler.Stapler.invoke(Stapler.java:649)
        at org.kohsuke.stapler.Stapler.service(Stapler.java:238)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
        at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:491)
        at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1074)
        at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:132)
        at hudson.util.PluginServletFilter.doFilter(PluginServletFilter.java:123)
        at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1065)
        at hudson.security.csrf.CrumbFilter.doFilter(CrumbFilter.java:49)
        at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1065)
        at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:84)
        at hudson.security.ChainedServletFilter.doFilter(ChainedServletFilter.java:76)
        at hudson.security.HudsonFilter.doFilter(HudsonFilter.java:171)
        at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1065)
        at org.kohsuke.stapler.compression.CompressionFilter.doFilter(CompressionFilter.java:49)
        at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1065)
        at hudson.util.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:81)
        at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1065)
        at org.kohsuke.stapler.DiagnosticThreadNameFilter.doFilter(DiagnosticThreadNameFilter.java:30)
        at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1065)
        at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:365)
        at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:185)
        at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
        at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:689)
        at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:391)
        at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:146)
        at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
        at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139)
        at org.mortbay.jetty.Server.handle(Server.java:285)
        at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:457)
        at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:765)
        at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:628)
        at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:209)
        at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:357)
        at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:329)
        at org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:475)
Changed the type of percentage to be Float instead of float and the exception disappeared, but the generated script still says "percentage: <object of type java.lang.Float>".

I expected the end result to look something like this.  
codesonar conditions: [warningCountIncreaseNewOnly(percentage: 5.0)], credentialId: 'c54378b6-c385-45bb-bd6d-bf5d8e51979a', hubAddress: '10.10.10.10', projectName: '${JOB_NAME}', protocol: 'http'

Does anyone have any suggestions regarding this?

Robert Sandell

unread,
Jan 24, 2017, 10:37:17 AM1/24/17
to jenkin...@googlegroups.com

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-dev+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/934e8188-fbf9-4b52-997e-0a190eee6eee%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Robert Sandell
Software Engineer
CloudBees Inc.

Björn Pedersen

unread,
Jan 24, 2017, 11:02:22 AM1/24/17
to Jenkins Developers
Looking at the pipeline devguide (https://github.com/jenkinsci/pipeline-plugin/blob/master/DEVGUIDE.md#variable-substitutions),
it seems like there should be setters/getters that transform from strings to the desired internal representation, instead of using
these types directly.

Björn
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-de...@googlegroups.com.

Jesse Glick

unread,
Jan 24, 2017, 12:14:42 PM1/24/17
to Jenkins Dev
On Tue, Jan 24, 2017 at 10:37 AM, Robert Sandell <rsan...@cloudbees.com> wrote:
> Looks similar to https://issues.jenkins-ci.org/browse/JENKINS-38004

JENKINS-31967 is the original.
Reply all
Reply to author
Forward
0 new messages