I'm trying to run a script that instantiates the extended choice parameter variable to use it in the declarative jenkinsfile properties section, but I haven't been able to run a script in the jenkinsfile without a step. I don't want to do it as an input step or as a scripted pipeline.
So I'm running it doing first a node step and then a pipeline step, like this:
import com.cwctravel.hudson.plugins.extended_choice_parameter.ExtendedChoiceParameterDefinition
node('MyServer') {
try {
def multiSelect = new ExtendedChoiceParameterDefinition(...)
properties([ parameters([ multiSelect ]) ])
}
catch(error){
echo "$error"
}
}
pipeline {
stages {
....
}
}
And magically it works! with a caveat, only if I have run a build before with only a pipeline block.
So, is there a better way to run a previous script to the pipeline? to be able to create the object for the properties or another place outside the steps to embed a script block?
I would rather go for parameters block in pipeline.