Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-72885

Add the api method to configure the 'Active Choices Reactive Parameter' 'Use Groovy Sandbox' attribute

XMLWordPrintable

    • Icon: New Feature New Feature
    • Resolution: Unresolved
    • Icon: Major Major
    • job-dsl-plugin
    • None
    • Jenkine Version: 2.440.1
      Job DSLVersion: 1.87

      Currently whenever the Job is configured with  'Active Choices Reactive Parameter' the default is 'Use Groovy Sandbox' is unselected, which is essential for the active choice proper functionality.

       

      Example job:

       

      pipelineJob('DynamicChoiceJob-DSL') {
        description('Test Job used for temporarily testing any pipeline run using the replay functionality')
        logRotator {
          numToKeep(120)
          daysToKeep(60)
        }
        parameters {
          booleanParam {
            name('RUN_TESTS')
            description('Run tests')
            defaultValue(true)
          }
          activeChoiceReactiveParam('TEST_TYPES') {
            description('Dynamic Test types based on the Run tests param')
            choiceType('CHECKBOX')
            referencedParameter('RUN_TESTS')
            groovyScript {
              
                script("""\
                if(RUN_TESTS) {
                  return ['default', 'code_coverage', 'newman']
                } else {
                  return []
                }
              """.stripIndent())
              
              
            }
          }
        }
      } 

       

      The result job is configured with the 'Use Groovy Sandbox' is unselected, which whenever the RUN_TESTS is selected/unselected nothing happens while when  'Use Groovy Sandbox' is manually selected in Job config. the functionality started to work as expected. (screen shots)

       

       

      Feature:

      Add the sandbox api method to the script and fallbackScript

      e.g.

      groovyScript {
        script { 
         script(String) 
         sandbox(Boolean) 
        }
        
        fallbackScript {
          script(String)
          sandbox(Boolean)
        }
      } 

       

            jamietanna Jamie Tanna
            harvynbb Harvy
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: