Home > Blockchain >  jobDSL does not understand the type of parameters
jobDSL does not understand the type of parameters

Time:08-11

While creating a Jenkins server, I use jobDSL to create jobs via pipeline.

Basically my created job ressembles this:

pipeline{
   parameters{
      string(name: "SAMPLE_PARAMETER")
   }
   stages{
      stage("Does not matter here"){
         //Does some work
      }
   }
}

When jobDSL tries to create a job out of this, I get an error saying that javaposse.jobdsl.dsl.helpers.BuildParametersContext.stringParam() can only work with (java.lang.string), (java.lang.string, java.lang.string) or (java.lang.string, java.lang.string, java.lang.string) and not with java.util.ArrayList

Can I force the type of "SAMPLE_PARAMETER", and if so how?

If this is not possible, how can I work around this?

CodePudding user response:

You are already passing type of variable. But if you still want to pass datatype, you can simply use it like this.

string SAMPLE_PARAMETER1 = params.SAMPLE_PARAMETER

or

def SAMPLE_PARAMETER1 = params.SAMPLE_PARAMETER
SAMPLE_PARAMETER1 = SAMPLE_PARAMETER1.toString()

CodePudding user response:

As suggested by Matt Schuchard in the comment he posted, I was missing the agent section, adding

agent any

fixed my issue. I have no clue how it's related but it fixed it

  • Related