Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-48127

Declarative Pipeline parameters: build fails with ProxyException / GroovyCastException

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Major Major
    • pipeline

      Using Jenkinsfile from SCM, trying to have input parameters on Jenkins leads to the following exception (regardless of the format of the input parameter, or whether or not it has been added manually to Jenkins beforehand):

       

      Checking out hg /Users/<user>/repo default into /Users/<user>/.jenkins/workspace/pipe@script to read Jenkinsfile
       Acquired master cache lock.
       [08AD0670BF75046CD08C0E2E69832FD1A73F4D57-repo-hg] $ /usr/local//bin/hg --config ******** pull
       pulling from /Users/<user>/repo
       searching for changes
       adding changesets
       adding manifests
       adding file changes
       added 1 changesets with 1 changes to 1 files
       (run 'hg update' to get a working copy)
       Master cache lock released.
       [pipe@script] $ /usr/local//bin/hg --config ******** pull --rev default /Users/<user>/.jenkins/hgcache/08AD0670BF75046CD08C0E2E69832FD1A73F4D57-repo-hg
       pulling from /Users/<user>/.jenkins/hgcache/08AD0670BF75046CD08C0E2E69832FD1A73F4D57-repo-hg
       no changes found
       [pipe@script] $ /usr/local//bin/hg --config ******** update --clean --rev default
       1 files updated, 0 files merged, 0 files removed, 0 files unresolved
       [pipe@script] $ /usr/local//bin/hg --config ******** log --rev . --template {node}
       [pipe@script] $ /usr/local//bin/hg --config ******** log --rev . --template {rev}
       [pipe@script] $ /usr/local//bin/hg --config ******** log --rev 0f607364c15cdf4398a90f9c111135ce04912d8e --template exists\n
       exists
       [pipe@script] $ /usr/local//bin/hg --config ******** log --template "<changeset node='{node}' author='{author|xmlescape}' rev='{rev}' date='{date}'><msg>{desc|xmlescape}</msg><added>{file_adds|stringify|xmlescape}</added><deleted>{file_dels|stringify|xmlescape}</deleted><files>{files|stringify|xmlescape}</files><parents>{parents}</parents></changeset>\n" --rev "ancestors('default') and not ancestors(0f607364c15cdf4398a90f9c111135ce04912d8e)" --encoding UTF-8 --encodingmode replace
       [pipe@script] $ /usr/local//bin/hg --config ******** log --rev . --template {node}
       [pipe@script] $ /usr/local//bin/hg --config ******** log --rev . --template {rev}
       Loading library repo-shared@default
       Acquired master cache lock.
       [08AD0670BF75046CD08C0E2E69832FD1A73F4D57-repo-hg] $ /usr/local//bin/hg --config ******** pull
       pulling from /Users/<user>/repo
       searching for changes
       no changes found
       Master cache lock released.
       [repo-shared] $ /usr/local//bin/hg --config ******** pull --rev default /Users/<user>/.jenkins/hgcache/08AD0670BF75046CD08C0E2E69832FD1A73F4D57-repo-hg
       pulling from /Users/<user>/.jenkins/hgcache/08AD0670BF75046CD08C0E2E69832FD1A73F4D57-repo-hg
       no changes found
       [repo-shared] $ /usr/local//bin/hg --config ******** update --clean --rev default
       1 files updated, 0 files merged, 0 files removed, 0 files unresolved
       [repo-shared] $ /usr/local//bin/hg --config ******** --config extensions.purge= clean --all
       [repo-shared] $ /usr/local//bin/hg --config ******** log --rev . --template {node}
       [repo-shared] $ /usr/local//bin/hg --config ******** log --rev . --template {rev}
       [repo-shared] $ /usr/local//bin/hg --config ******** log --rev 0f607364c15cdf4398a90f9c111135ce04912d8e --template exists\n
       exists
       [repo-shared] $ /usr/local//bin/hg --config ******** log --template "<changeset node='{node}' author='{author|xmlescape}' rev='{rev}' date='{date}'><msg>{desc|xmlescape}</msg><added>{file_adds|stringify|xmlescape}</added><deleted>{file_dels|stringify|xmlescape}</deleted><files>{files|stringify|xmlescape}</files><parents>{parents}</parents></changeset>\n" --rev "ancestors('default') and not ancestors(0f607364c15cdf4398a90f9c111135ce04912d8e)" --encoding UTF-8 --encodingmode replace
       [repo-shared] $ /usr/local//bin/hg --config ******** log --rev . --template {node}
       [repo-shared] $ /usr/local//bin/hg --config ******** log --rev . --template {rev}
       [Pipeline] stage
       [Pipeline] { (Declarative: Post Actions)
       [Pipeline] echo
       BUILD RESULT-02: null
       [Pipeline] }
       [Pipeline] // stage
       [Pipeline] End of Pipeline
       hudson.remoting.ProxyException: org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object '{name=booleanParam, args={defaultValue=true, description=, name=flag}}' with class 'java.util.LinkedHashMap' to class 'hudson.model.Describable' due to: groovy.lang.GroovyRuntimeException: Could not find matching constructor for: hudson.model.Describable(java.util.LinkedHashMap)
       at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.continueCastOnSAM(DefaultTypeTransformation.java:403)
       at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.continueCastOnNumber(DefaultTypeTransformation.java:319)
       at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.castToType(DefaultTypeTransformation.java:232)
       at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.castToType(ScriptBytecodeAdapter.java:603)
       at org.jenkinsci.plugins.pipeline.modeldefinition.Utils$_instantiateList_closure6.doCall(Utils.groovy:445)
       at sun.reflect.GeneratedMethodAccessor971.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
       at java.lang.reflect.Method.invoke(Method.java:498)
       at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
       at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
       at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:294)
       at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)
       at groovy.lang.Closure.call(Closure.java:414)
       at groovy.lang.Closure.call(Closure.java:430)
       at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2040)
       at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2025)
       at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2066)
       at com.cloudbees.groovy.cps.CpsDefaultGroovyMethods.each(CpsDefaultGroovyMethods.java:915)
       at sun.reflect.GeneratedMethodAccessor652.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
       at java.lang.reflect.Method.invoke(Method.java:498)
       at org.codehaus.groovy.runtime.metaclass.ReflectionMetaMethod.invoke(ReflectionMetaMethod.java:54)
       at org.codehaus.groovy.runtime.metaclass.NewInstanceMetaMethod.invoke(NewInstanceMetaMethod.java:56)
       at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
       at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1213)
       at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)
       at org.codehaus.groovy.runtime.callsite.PojoMetaClassSite.call(PojoMetaClassSite.java:47)
       at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
       at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:57)
       at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
       at org.jenkinsci.plugins.pipeline.modeldefinition.Utils.instantiateList(Utils.groovy:441)
       at sun.reflect.GeneratedMethodAccessor691.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
       at java.lang.reflect.Method.invoke(Method.java:498)
       at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
       at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite$StaticMetaMethodSiteNoUnwrapNoCoerce.invoke(StaticMetaMethodSite.java:151)
       at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite.callStatic(StaticMetaMethodSite.java:102)
       at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:214)
       at org.jenkinsci.plugins.pipeline.modeldefinition.Utils.updateJobProperties(Utils.groovy:473)
       at org.jenkinsci.plugins.pipeline.modeldefinition.Utils$updateJobProperties$7.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 com.cloudbees.groovy.cps.sandbox.DefaultInvoker.methodCall(DefaultInvoker.java:19)
       at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.executeProperties(jar:file:/Users/mehdychaillou/.jenkins/plugins/pipeline-model-definition/WEB-INF/lib/pipeline-model-definition.jar!/org/jenkinsci/plugins/pipeline/modeldefinition/ModelInterpreter.groovy:620)
       at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.call(jar:file:/Users/mehdychaillou/.jenkins/plugins/pipeline-model-definition/WEB-INF/lib/pipeline-model-definition.jar!/org/jenkinsci/plugins/pipeline/modeldefinition/ModelInterpreter.groovy:65)
       at WorkflowScript.run(WorkflowScript:4)
       at __cps.transform__(Native Method)
       at com.cloudbees.groovy.cps.impl.ContinuationGroup.methodCall(ContinuationGroup.java:57)
       at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.dispatchOrArg(FunctionCallBlock.java:109)
       at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.fixArg(FunctionCallBlock.java:82)
       at sun.reflect.GeneratedMethodAccessor226.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
       at java.lang.reflect.Method.invoke(Method.java:498)
       at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
       at com.cloudbees.groovy.cps.impl.PropertyishBlock$ContinuationImpl.get(PropertyishBlock.java:76)
       at com.cloudbees.groovy.cps.LValueBlock$GetAdapter.receive(LValueBlock.java:30)
       at com.cloudbees.groovy.cps.impl.PropertyishBlock$ContinuationImpl.fixName(PropertyishBlock.java:66)
       at sun.reflect.GeneratedMethodAccessor232.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
       at java.lang.reflect.Method.invoke(Method.java:498)
       at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
       at com.cloudbees.groovy.cps.impl.ConstantBlock.eval(ConstantBlock.java:21)
       at com.cloudbees.groovy.cps.Next.step(Next.java:83)
       at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:174)
       at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:163)
       at org.codehaus.groovy.runtime.GroovyCategorySupport$ThreadCategoryInfo.use(GroovyCategorySupport.java:122)
       at org.codehaus.groovy.runtime.GroovyCategorySupport.use(GroovyCategorySupport.java:261)
       at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:163)
       at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.access$001(SandboxContinuable.java:19)
       at org.jenkinsci.plugins.workflow.cps.SandboxContinuable$1.call(SandboxContinuable.java:35)
       at org.jenkinsci.plugins.workflow.cps.SandboxContinuable$1.call(SandboxContinuable.java:32)
       at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovySandbox.runInSandbox(GroovySandbox.java:108)
       at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.run0(SandboxContinuable.java:32)
       at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:174)
       at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:330)
       at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$100(CpsThreadGroup.java:82)
       at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:242)
       at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:230)
       at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:64)
       at java.util.concurrent.FutureTask.run(FutureTask.java:266)
       at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:112)
       at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
       at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
       at java.util.concurrent.FutureTask.run(FutureTask.java:266)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
       at java.lang.Thread.run(Thread.java:748)
       Finished: FAILURE

       

      The rest of the pipeline executes itself, but the total build fails, and most obviously, I can't use input parameters.

      The pipeline:

      pipeline {
         agent any
      
         options {
            timeout(time: 60, unit: 'MINUTES')
         }
      
         parameters {
            booleanParam(defaultValue: true, description: '', name: 'flag')
            string(defaultValue: '', description: '', name: 'SOME_STRING')
         }
      
         tools {
            maven 'M3'
            maven 'mvn3.5.2'
            jdk 'jdk8'
         }
      
         stages {
            stage('Test') {
               steps {
                  print "BUILD RESULT-01: " + currentBuild.result
               }
            }
         }
      
         post {
            always {
               print "BUILD RESULT-02: "+currentBuild.result
            }
         }
      }
      

       

      Let me know if there's anything else I can provide for additional info.

            Unassigned Unassigned
            cmehdy Mehdy Chaillou
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: