Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NoStaplerConstructorException for addGitLabMRComment #410

Closed
avdv opened this issue Sep 12, 2016 · 0 comments
Closed

NoStaplerConstructorException for addGitLabMRComment #410

avdv opened this issue Sep 12, 2016 · 0 comments

Comments

@avdv
Copy link

avdv commented Sep 12, 2016

Issue

Context

  • Gitlab plugin version: 1.4.0
  • Gitlab version: 8.x EE (I cannot say which version, but it has the TODO feature, so I think it is at least 8.5)
  • Jenkins version: 2.7.3

Problem description

I have a pipeline job, where I'm trying to submit a comment at the end of the build, I'm using the code from the migration guide:

def resultIcon = currentBuild.result == 'SUCCESS' ? ':white_check_mark:' : ':anguished:'
addGitLabMRComment comment: "$resultIcon Jenkins Build $currentBuild.result\n\nResults available at: [Jenkins [$env.JOB_NAME#$env.BUILD_NUMBER]]($env.BUILD_URL)"

I get this exception:

org.kohsuke.stapler.NoStaplerConstructorException: There's no @DataBoundConstructor on any constructor of class java.lang.String
    at org.kohsuke.stapler.ClassDescriptor.loadConstructorParamNames(ClassDescriptor.java:247)
    at org.jenkinsci.plugins.structs.describable.DescribableModel.<init>(DescribableModel.java:121)
    at org.jenkinsci.plugins.structs.describable.DescribableModel.coerce(DescribableModel.java:372)
    at org.jenkinsci.plugins.structs.describable.DescribableModel.buildArguments(DescribableModel.java:313)
    at org.jenkinsci.plugins.structs.describable.DescribableModel.instantiate(DescribableModel.java:257)
    at org.jenkinsci.plugins.workflow.steps.StepDescriptor.newInstance(StepDescriptor.java:195)
    at org.jenkinsci.plugins.workflow.cps.DSL.invokeStep(DSL.java:181)
    at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:126)
    at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:120)
    at groovy.lang.GroovyObject$invokeMethod.call(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
    at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:151)
    at org.kohsuke.groovy.sandbox.GroovyInterceptor.onMethodCall(GroovyInterceptor.java:21)
    at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:115)
    at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:149)
    at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:146)
    at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:123)
    at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.methodCall(SandboxInvoker.java:16)
    at WorkflowScript.run(WorkflowScript:49)

I've attached a debugger and it sems the problem comes from the usage of the comment: argument passing, trying to coerce a java.util.LinkedHashMap to a String in https://github.com/jenkinsci/structs-plugin/blob/master/plugin/src/main/java/org/jenkinsci/plugins/structs/describable/DescribableModel.java#L372 -- values of the variables at that point are:

Running CpsFlowExecution[Owner[job-A/32:job-A #32]][3] print context
 context = "com.dabsquared.gitlabjenkins.workflow.AddGitLabMergeRequestCommentStep.comment"
Running CpsFlowExecution[Owner[job-A/32:job-A #32]][3] print type
 type = "class java.lang.String"
Running CpsFlowExecution[Owner[job-A/32:job-A #32]][3] print o
 o = "{comment=:white_check_mark: Jenkins Build SUCCESS

Results available at: [Jenkins [#32#32]](http://localhost:7070/jenkins/job/job-A/32/)}"

Using the following code instead works successfully:

addGitLabMRComment "$resultIcon Jenkins Build $currentBuild.result\n\nResults available at: [Jenkins [$env.JOB_NAME#$env.BUILD_NUMBER]]($env.BUILD_URL)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant