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

execute commands such as git inside jenkins DSL plugin for dynamic parameters

    Details

    • Similar Issues:

      Description

      Would like to generate dynamic choices from git repository. So, within groovySrcipt's script section,

       

      properties([
       parameters([ 
        [$class: 'ChoiceParameter',
         choiceType: 'PT_SINGLE_SELECT',
         description: 'Choose env',
         name: 'ENVIRONMENT',
         sandbox: true,
         script: 'return["none","dev","int","prod"]' ] 
      script: [ 
         $class: 'GroovyScript',
          fallbackScript: [
       classpath: [], 
         sandbox: true, 
         script: 'return[\'Environment not found\']' ], 
         script: [ classpath: [], ] ], 
          [$class: 'CascadeChoiceParameter', 
           choiceType: 'PT_SINGLE_SELECT', 
           description: 'Choose snapshot for selected env', 
           name: 'SNAPSHOT', 
           referencedParameters: 'ENVIRONMENT', 
           script: [ $class: 'GroovyScript', 
           fallbackScript: 
           [ classpath: [], 
           sandbox: true, 
            script: 'return["FAILED"]' ], 
            script: [ classpath: [], 
            sandbox: true, 
            script: """ 
                 def snapshotsL = "git tag -l --sort=v:refname \"v*-SNAPSHOT\" | tail -5" 
                  return [snapshotsL] """ ] ] ] ]) ])
      
      
      Above script always returns FAILED. Either I am not sure, how to capture the git command out and return or this functionality isn't available.
      
      Please assist.

        Attachments

          Activity

          Hide
          ioannis Ioannis Moutsatsos added a comment -

          The recommended way for troubleshooting Active Choice scripts is from the Jenkins Groovy console. Write your script and variables as they will be used in the job and test the script until it works correctly and returns the required data structure for the Active Choice type you are using.

          In the context of a freestyle job Active Choice parameters are reported to the Chrome javascript console and that is also helpful for troubleshooting. Hope this helps 

          Show
          ioannis Ioannis Moutsatsos added a comment - The recommended way for troubleshooting Active Choice scripts is from the Jenkins Groovy console. Write your script and variables as they will be used in the job and test the script until it works correctly and returns the required data structure for the Active Choice type you are using. In the context of a freestyle job Active Choice parameters are reported to the Chrome javascript console and that is also helpful for troubleshooting. Hope this helps 

            People

            • Assignee:
              kinow Bruno P. Kinoshita
              Reporter:
              srji SR
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: