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

deployment using bbs_checkout always ends up in java.lang.ClassCastException: class com.atlassian.bitbucket.jenkins.internal.scm.BitbucketSCMStep.setBranches() expects java.util.List<hudson.plugins.git.BranchSpec> but received class java.lang.String

XMLWordPrintable

      Hello, this might be more of a question then a bug but I'm a bit lost so I'm giving this a try.

      I'm trying to create a pipeline to test the atlassian-bitbucket-server-integration-plugin

      To do what I need to do (have a central pipeline that verifies projects and then checkouts a project and updates bitbucket on it) I think I need to use this bbs_checkout feature.

      I'm trying to do something like this:
      https://github.com/jenkinsci/atlassian-bitbucket-server-integration-plugin/blob/master/src/test/resources/deployments/DeploymentJenkinsfileWithCheckout

      Off course a bit more elaborate

      I've tried a lot of different things for the "branches" section because I need to pass a specific commit or branch.
      I always end up in this error:

      java.lang.ClassCastException: class com.atlassian.bitbucket.jenkins.internal.scm.BitbucketSCMStep.setBranches() expects java.util.List<hudson.plugins.git.BranchSpec> but received class java.lang.String
      

      This is the latest call stack error from one of my tries:

      java.lang.ClassCastException: class com.atlassian.bitbucket.jenkins.internal.scm.BitbucketSCMStep.setBranches() expects java.util.List<hudson.plugins.git.BranchSpec> but received class java.lang.String
      	at org.jenkinsci.plugins.structs.describable.DescribableModel.coerce(DescribableModel.java:492)
      	at org.jenkinsci.plugins.structs.describable.DescribableModel.injectSetters(DescribableModel.java:429)
      	at org.jenkinsci.plugins.structs.describable.DescribableModel.instantiate(DescribableModel.java:331)
      	at org.jenkinsci.plugins.workflow.cps.DSL.invokeStep(DSL.java:305)
      	at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:196)
      	at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:124)
      	at jdk.internal.reflect.GeneratedMethodAccessor1141.invoke(Unknown Source)
      	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
      	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:98)
      	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
      	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1225)
      	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1034)
      	at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:41)
      	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
      	at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:180)
      	at org.kohsuke.groovy.sandbox.GroovyInterceptor.onMethodCall(GroovyInterceptor.java:23)
      	at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:163)
      	at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:178)
      	at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:182)
      	at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:152)
      	at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:152)
      	at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.methodCall(SandboxInvoker.java:17)
      Caused: java.lang.IllegalArgumentException: Could not instantiate {projectName=**, repositoryName=**, branches=[[name: '<98d605fc1ab2b9d83faf1ee0790a5c4fa89715ce>']], changelog=false, credentialsId=**, poll=false, serverId=**, sshCredentialsId=**} for com.atlassian.bitbucket.jenkins.internal.scm.BitbucketSCMStep
      

      As for what I've tried based on the documentation here:
      https://www.jenkins.io/doc/pipeline/steps/atlassian-bitbucket-server-integration/#bbs_deploy-wrapper-step-to-notify-bitbucket-server-of-the-deployment-status

      Last try

              stage('Checkout project') {
                  steps {
                      script {
                          bbs_checkout(
                              projectName: "${PROJECT}",
                              repositoryName: "${REPOSITORY}",
                              branches: "[[name: '${COMMIT}']]",
                              changelog: false,
                              credentialsId: '**',
                              poll: false,
                              serverId: 'serverName',
                              sshCredentialsId: '**'
                          )
                      }
                  }
              }
      

      Previous tries all based on just changing the branches parameter to:

                              branches: "[name: '${BRANCH}']",
      
                              branches: "[[name: '${BRANCH}']]",
      
                              branches: "[name: <'${COMMIT}'>]",
      

      Somehow the problem is that it does never try to convert that String into a BranchSpec and I don't think I can force the creation of such a spec.

      Thank you for any feedback

            djansons David
            mcosta Miguel Costa
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: