Issue accesing variable inside script in ActiveChoice plugin (ver2.4)

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Issue accesing variable inside script in ActiveChoice plugin (ver2.4)

chencho m-a
Hi all, 

I have a script which is writting the configuration of ActiveChoice instead of use the browser. 

So I am sending a hashmap as parameters but I am unable to acces it inside the script 

def components_param(hash_map){ // Section header
    return [$class: 'DynamicReferenceParameter',
            choiceType: 'ET_FORMATTED_HTML', 
            description: '', 
            name: '', 
            randomName: "choice-parameter-${UUID.randomUUID()}",
            omitValueField: false,
            referencedParameters: 'sdk',
            script: [
                $class: 'GroovyScript',
                fallbackScript: [
                    classpath: [], sandbox: false, script: 'return ["Error,can\'t retrieve components"]',
                    ],
                script: [
                    classpath: [], sandbox: false, script:'''
def output="<font size='3'><b>Components to be updated ${sdk}</b></font><ul>"
for (comp in  '''+hash_map+'''[sdk].keySet()) {
        output += "<li>"+comp+"</li>"
}

output+="</ul>"
return output
            '''
                    ]
                ]                           
            ]
}

If I check the content in jenkins UI, i got this error:

startup failed:
Script1: 3: illegal colon after argument expression;
   solution: a complex label expression before a colon must be parenthesized @ line 3, column 43.

The hash_map in jenkins UI takes this form:

 [devel:[extensions:[extension1:[data:[name:name1, type:generic], sdk-ext:sdk-ext-extension1-devel,  extension1-release: extension1-sdk-1.21.0.0-devel, ...

How can I parse this hashmap inside ActiveChoice script? In any groovy console is something like:

sdks=hash_map.keySet()
sdk=sdks[1]
for (comp in hash_map[sdk].keySet()) {
    println comp
}

Any help will be appreciated

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/f8746735-501c-4a9e-91b3-3a423eb3125fn%40googlegroups.com.