'Jenkins - How to handle checkbox in Active choice reactive reference parameter

I tried setting up active choice reactive reference parameter as given in the link : https://www.infracloud.io/blogs/render-jenkins-build-parameters-dynamically/

reactive reference paramter code :

service_tier_map = [
  "web": [
    ["service_name": "user_frontend", "release_tag": "1.0.0" ],
    ["service_name": "admin_frontend", "release_tag": "1.0.2" ],
  ],
  "backend": [
    ["service_name": "admin_service", "release_tag": "2.1.0" ],
    ["service_name": "finance_service", "release_tag": "2.2.0" ],
    ["service_name": "payment_service", "release_tag": "3.2.0" ],
  ],
  "database": [
    ["service_name": "dynamo_db", "release_tag": "5.4.1"],
    ["service_name": "mysql", "release_tag": "3.2.1"],
    ["service_name": "postgresql", "release_tag": "1.2.3"],
  ],
]

html_to_be_rendered = "<table><tr>"
service_list = service_tier_map[tier]
service_list.each { service ->
  html_to_be_rendered = """
    ${html_to_be_rendered}
    <tr>
    <td>
    <input name=\"value\" alt=\"${service.service_name}\" json=\"${service.service_name}\" type=\"checkbox\" class=\" \">
    <label title=\"${service.service_name}\" class=\" \">${service.service_name}</label>
    </td>
    <td>
    <input type=\"text\" class=\" \" name=\"value\" value=\"${service.release_tag}\"> </br>
    </td>
    </tr>
"""
}


html_to_be_rendered = "${html_to_be_rendered}</tr></table>"

return html_to_be_rendered

Pipeline code :

pipeline {
  agent any

  stages {
    stage('Demo Active Choices Parameter') {
      steps {
        echo "Tier Selected ${tier}"
        echo "Services Selected ${services}"
      }
    }
  }
}

Pipeline output :


[Pipeline] echo
Tier Selected web
[Pipeline] echo
Services Selected true,1.0.0,false,1.0.2,
[Pipeline] }

The output is coming as true false instead of the value selected. I specified alt and Json. Is there a way to get the value of the checkbox ?



Solution 1:[1]

Make sure to disable sandbox for the parameter

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Macarescu Sebastian