passing parameters/arguments to a groovy script outside of pipeline stages

100 views
Skip to first unread message

Mike MBS

unread,
Oct 15, 2023, 3:24:32 PM10/15/23
to Jenkins Users
I am trying to create an Active Choice input that will dynamically change its values based on another combo box.  The code is below...when i run this, it the 'select_tag' input is not populated.   I see one warning in the jenkins console output: ``` WARNING: Unknown parameter(s) found for class type 'org.biouno.unochoice.model.GroovyScript': parameters```

But nothing else.  Anyone know how to do this properly?
How do we debug these kind of scripts that are run on initialization of the page?  where are the exceptions outputs logged to?

```

def proj_tag_map = ['proj1': ['1.0.0', '1.0.1'], 'proj2': ['2.0.0', '2.0.1'] ]
def projects = proj_tag_map.keySet() as ArrayList

build_tag_input(proj_tag_map)

pipeline {
agent any
parameters{
  choice(name: 'project', choices: projects)
}
...
...
}

def build_tag_input(proj_tag_map){
   properties([
      parameters([
         [$class: 'CascadeChoiceParameter',
            choiceType: 'PT_SINGLE_SELECT',
            name: 'select_tag',
            referencedParameters: 'project',
            script: [
                  $class: 'GroovyScript',
                  parameters: [[name:'proj_tag_map', value: proj_tag_map]],                        
                  script: [

                     sandbox: true,
                     script: """
                        return proj_tag_map[project]
                     """.stripIndent()
                  ]
            ]
         ]
      ])
   ])
}  
````

Reply all
Reply to author
Forward
0 new messages