Answers: <p>You can use the Jenkins pipeline syntax to get the groovy script.  For example below code will generate radio buttons for active choice parameter. you can generate scripts like this from your jenkins instance at  <a href="http://localhost:8080/pipeline-syntax/" rel="nofollow noreferrer">http://localhost:8080/pipeline-syntax/</a>. More info is here <a href="https://jenkins.io/doc/book/pipeline/getting-started/#snippet-generator" rel="nofollow noreferrer">https://jenkins.io/doc/book/pipeline/getting-started/#snippet-generator</a></p>
  
  <pre><code>def createInputParameters(){
  ([[$class: 'RebuildSettings', autoRebuild: false, rebuildDisabled: false],
   parameters([[$class: 'ChoiceParameter', choiceType: 'PT_RADIO', description: '',
   filterLength: 1, filterable: false, name: 'Select_snapshot_or_release',
    randomName: 'choice-parameter-1683871426502398',
     script: [$class: 'GroovyScript', fallbackScript: [classpath: [], sandbox: true, 
      script: 'return "Error"'],
       script: [classpath: [], sandbox: true,
        script: '''return[
              \'snapshots\',\'release\']''']]]]),
               [$class: 'ThrottleJobProperty', categories: [],
                limitOneJobWithMatchingParams: false, maxConcurrentPerNode: 0, 
                 maxConcurrentTotal: 0,
                 paramsToUseForLimit: '', throttleEnabled: false, throttleOption: 
                 'project']])
        }
  </code></pre>
  
Answers: CC BY-SA 4.0
Answers: 2018-11-29T05:12:06.830Z
Answers: 2018-11-29T05:12:06.830Z
Answers: vishwas gautam
Body: <p><a href="https://i.sstatic.net/MmC0u.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/MmC0u.png" alt="gr"></a></p>
  
  <p>I used jenkins Active choices plugin and Mavenmetadata plugin to build above UI. When I click a radio button particular version only should be display. How can I write a groovy script to fulfill above requirement?</p>
  
  <p>Below images showing my groovy scripts. </p>
  
  <p><a href="https://i.sstatic.net/XzEVn.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/XzEVn.png" alt="active"></a></p>
  
  <p><a href="https://i.sstatic.net/Y5W8p.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/Y5W8p.png" alt="snap"></a></p>
  
Tags: <jenkins><jenkins-plugins><groovy>
Title: Groovy script to show only selected item
UserDisplayName: Janith
ThreadText: # Groovy script to show only selected item
  
  (Asked by: username_0 on 2018-11-19)
  
  [![gr](https://i.sstatic.net/MmC0u.png)](https://i.sstatic.net/MmC0u.png)
  
  I used jenkins Active choices plugin and Mavenmetadata plugin to build above UI. When I click a radio button particular version only should be display. How can I write a groovy script to fulfill above requirement?
  
  Below images showing my groovy scripts.
  
  [![active](https://i.sstatic.net/XzEVn.png)](https://i.sstatic.net/XzEVn.png)
  
  [![snap](https://i.sstatic.net/Y5W8p.png)](https://i.sstatic.net/Y5W8p.png)
  
  **Tags:** jenkins, jenkins-plugins, groovy
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-11-29. Score: 1
  
  You can use the Jenkins pipeline syntax to get the groovy script. For example below code will generate radio buttons for active choice parameter. you can generate scripts like this from your jenkins instance at <http://localhost:8080/pipeline-syntax/>. More info is here <https://jenkins.io/doc/book/pipeline/getting-started/#snippet-generator>
  
  ```
  def createInputParameters(){
  ([[$class: 'RebuildSettings', autoRebuild: false, rebuildDisabled: false],
   parameters([[$class: 'ChoiceParameter', choiceType: 'PT_RADIO', description: '',
   filterLength: 1, filterable: false, name: 'Select_snapshot_or_release',
    randomName: 'choice-parameter-1683871426502398',
     script: [$class: 'GroovyScript', fallbackScript: [classpath: [], sandbox: true, 
      script: 'return "Error"'],
       script: [classpath: [], sandbox: true,
        script: '''return[
              \'snapshots\',\'release\']''']]]]),
               [$class: 'ThrottleJobProperty', categories: [],
                limitOneJobWithMatchingParams: false, maxConcurrentPerNode: 0, 
                 maxConcurrentTotal: 0,
                 paramsToUseForLimit: '', throttleEnabled: false, throttleOption: 
                 'project']])
        }
  
  ```
  
  
  ---
  
  