Answers: <p><strong>EDIT:</strong> Updating my answer to include steps on using the Declarative Directive Generator.</p>
  
  <p>You can experiment with the different available configuration options, and sometimes gets hints as to what certain settings provide. For this specific case:</p>
  
  <ol>
  <li>Navigate to <code>&lt;$JENKINS_URL&gt;/directive-generator/</code></li>
  <li>Select <code>parameters: Parameters</code> from the <strong>Sample Directive</strong> drop-down.</li>
  <li>Click the <strong>Add</strong> button and select <code>extendedChoice: Extended Choice Parameter</code></li>
  <li>Select <code>JSON Parameter Type</code> and then experiment with the available options.</li>
  <li>When finished, click <strong>Generate Declarative Directive</strong> to generate the code block to paste into your pipeline.</li>
  </ol>
  
  <p><a href="https://i.sstatic.net/HU20V.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/HU20V.png" alt="Using the Declarative Directive Generator"></a></p>
  
  <p>You can add the <code>javascriptFile</code> parameter and change the <code>type</code> to <code>PT_JSON</code>.</p>
  
  <p>Using your example:</p>
  
  <pre><code>properties([
      [$class: 'BuildDiscarderProperty', strategy: [$class: 'LogRotator', numToKeepStr: '500']],
      parameters([extendedChoice( 
      defaultValue: 'One,Two,Three,Four', 
      description: '', 
      javascriptFile: '/path/to/file.json',
      multiSelectDelimiter: ',', 
      name: 'SAMPLE_EXTENDED_CHOICE', 
      quoteValue: false, 
      saveJSONParameterToFile: false, 
      type: 'PT_JSON', 
      value:'One,Two,Three,Four,Five,Six,Seven,Eight,Nine,Ten', 
      visibleItemCount: 10)
  </code></pre>
  
Answers: CC BY-SA 4.0
Answers: 2020-05-19T00:16:33.393Z
Answers: I am having Jenkins file (with properties/parameters) in source code of the repo for which I am doing the build. Can I put json file also in the repo.
Answers: Vineel
Answers: CC BY-SA 4.0
Answers: 2020-05-20T01:48:33.410Z
Answers: Do you mean can you have a JSON file within the same repo that's being built? Sure, just checkout the repo then you can read the local file using `readJSON()` https://www.jenkins.io/doc/pipeline/steps/pipeline-utility-steps/#readjson-read-json-from-files-in-the-workspace
Answers: Argyle
Answers: CC BY-SA 4.0
Answers: 2020-05-20T17:20:25.403Z
Answers: for JavaScriptFile attribute, we need to give path to the JSON file right?  Where should that file exist?
Answers: Vineel
Answers: CC BY-SA 4.0
Answers: 2020-05-21T21:13:44.817Z
Answers: @Vineel please see updated answer for steps on how you can try the different available configuration options to see what works for your situation.
Answers: Argyle
Answers: CC BY-SA 4.0
Answers: 2020-05-21T21:32:00.937Z
Answers: 1) Jenkins file: https://github.com/vineelyalamarthy/PriceAnalyzer/blob/master/Jenkinsfile#L11 and 2) my JSON file. 2)https://github.com/vineelyalamarthy/PriceAnalyzer/blob/master/test_data.json   This combination didn't seem to work.
Answers: Vineel
Answers: CC BY-SA 4.0
Answers: 2020-05-21T21:35:21.263Z
Answers: Can you post the error?
Answers: Argyle
Answers: CC BY-SA 4.0
Answers: 2020-05-21T21:44:46.500Z
Answers: No error. on the UI only name "SAMPLE_EXTENDED_CHOICE'" gets shown and nothing else. Let me go to the Jenkins UI and see if there are any errors.
Answers: Vineel
Answers: CC BY-SA 4.0
Answers: 2020-05-21T21:48:37.797Z
Answers: ERROR log : https://gist.github.com/vineelyalamarthy/f291d53e47feda75ea58988aefc24314
Answers: Vineel
Answers: CC BY-SA 4.0
Answers: 2020-05-21T22:33:07.207Z
Answers: Acoording to the third answer in this post: https://stackoverflow.com/questions/48041687/jenkins-fetching-the-value-of-a-json-extended-choice-parameter, it looks like you can use the Groovy Script option to return a JSON object, which also appears to be the case in the plugin's documentation (2nd pic): https://wiki.jenkins.io/display/JENKINS/Extended%20Choice%20Parameter%20plugin
Answers: Argyle
Answers: CC BY-SA 4.0
Answers: 2020-05-21T22:45:24.243Z
Answers: You mean Groovy script can can have the logic of reading the file and create a JSON object?
Answers: Vineel
Answers: CC BY-SA 4.0
Answers: 2020-05-21T22:50:10.117Z
Answers: That's one way. Another way could be directly accessing the source -- like whatever generates the values in your JSON file.
Answers: Argyle
Answers: CC BY-SA 4.0
Answers: 2020-05-22T01:01:35.660Z
Answers: Finally I tried this and still no luck.     extendedChoice (bindings: '', description: '', groovyClasspath: '', groovyScript: '''
                  import org.boon.Boon;
                  def data = new File('data_from_eric.json').getText('UTF-8');
                  def jsonEditorOptions = Boon.fromJson('${data}');
                  return jsonEditorOptions;
                  ''', multiSelectDelimiter: ',', name: 'Policy12345', quoteValue: false, saveJSONParameterToFile: false, type: 'PT_JSON', visibleItemCount: 5)
Answers: Vineel
Answers: CC BY-SA 4.0
Answers: 2020-05-18T18:28:37.817Z
Answers: 2020-05-21T21:12:17.027Z
Answers: 2020-05-21T21:12:17.027Z
Answers: Argyle
Body: <p><strong>Extended Choice Parameter plugin query</strong>: How to load params dynamically from a JSON file for jenkins build job. Here is my jenkins script to add normal parameters and Extended Choice parameters as well.</p>
  
  <p>p</p>
  
  <pre><code>roperties([
          [$class: 'BuildDiscarderProperty', strategy: [$class: 'LogRotator', numToKeepStr: '500']],
          parameters([extendedChoice( 
          defaultValue: 'One,Two,Three,Four', 
          description: '', 
          multiSelectDelimiter: ',', 
          name: 'SAMPLE_EXTENDED_CHOICE', 
          quoteValue: false, 
          saveJSONParameterToFile: false, 
          type: 'PT_CHECKBOX', 
          value:'One,Two,Three,Four,Five,Six,Seven,Eight,Nine,Ten', 
          visibleItemCount: 10)
          ])
  ])
  </code></pre>
  
  <p>This is working. But I want to be able to load parameters from a JSON file (using Extended Choice Parameter plugin). How can I modify the above script to accomplish that? PS: Here is the reference for Extended Parameter plugin. <a href="https://plugins.jenkins.io/extended-choice-parameter/" rel="nofollow noreferrer">https://plugins.jenkins.io/extended-choice-parameter/</a></p>
  
Tags: <jenkins><jenkins-pipeline><jenkins-plugins>
Title: Jenkins Plugin:Extended Choice Parameter from JSON file
UserDisplayName: Vineel
ThreadText: # Jenkins Plugin:Extended Choice Parameter from JSON file
  
  (Asked by: username_0 on 2020-05-17)
  
  **Extended Choice Parameter plugin query**: How to load params dynamically from a JSON file for jenkins build job. Here is my jenkins script to add normal parameters and Extended Choice parameters as well.
  
  p
  
  ```
  roperties([
          [$class: 'BuildDiscarderProperty', strategy: [$class: 'LogRotator', numToKeepStr: '500']],
          parameters([extendedChoice( 
          defaultValue: 'One,Two,Three,Four', 
          description: '', 
          multiSelectDelimiter: ',', 
          name: 'SAMPLE_EXTENDED_CHOICE', 
          quoteValue: false, 
          saveJSONParameterToFile: false, 
          type: 'PT_CHECKBOX', 
          value:'One,Two,Three,Four,Five,Six,Seven,Eight,Nine,Ten', 
          visibleItemCount: 10)
          ])
  ])
  
  ```
  
  This is working. But I want to be able to load parameters from a JSON file (using Extended Choice Parameter plugin). How can I modify the above script to accomplish that? PS: Here is the reference for Extended Parameter plugin. <https://plugins.jenkins.io/extended-choice-parameter/>
  
  **Tags:** jenkins, jenkins-pipeline, jenkins-plugins
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2020-05-18. Score: 1
  
  **EDIT:** Updating my answer to include steps on using the Declarative Directive Generator.
  
  You can experiment with the different available configuration options, and sometimes gets hints as to what certain settings provide. For this specific case:
  
  1. Navigate to `<$JENKINS_URL>/directive-generator/`
  2. Select `parameters: Parameters` from the **Sample Directive** drop-down.
  3. Click the **Add** button and select `extendedChoice: Extended Choice Parameter`
  4. Select `JSON Parameter Type` and then experiment with the available options.
  5. When finished, click **Generate Declarative Directive** to generate the code block to paste into your pipeline.
  
  [![Using the Declarative Directive Generator](https://i.sstatic.net/HU20V.png)](https://i.sstatic.net/HU20V.png)
  
  You can add the `javascriptFile` parameter and change the `type` to `PT_JSON`.
  
  Using your example:
  
  ```
  properties([
      [$class: 'BuildDiscarderProperty', strategy: [$class: 'LogRotator', numToKeepStr: '500']],
      parameters([extendedChoice( 
      defaultValue: 'One,Two,Three,Four', 
      description: '', 
      javascriptFile: '/path/to/file.json',
      multiSelectDelimiter: ',', 
      name: 'SAMPLE_EXTENDED_CHOICE', 
      quoteValue: false, 
      saveJSONParameterToFile: false, 
      type: 'PT_JSON', 
      value:'One,Two,Three,Four,Five,Six,Seven,Eight,Nine,Ten', 
      visibleItemCount: 10)
  
  ```
  
  > **Comments:**
  > **username_0**: I am having Jenkins file (with properties/parameters) in source code of the repo for which I am doing the build. Can I put json file also in the repo.  
  > **username_1**: Do you mean can you have a JSON file within the same repo that's being built? Sure, just checkout the repo then you can read the local file using `readJSON()` https://www.jenkins.io/doc/pipeline/steps/pipeline-utility-steps/#readjson-read-json-from-files-in-the-workspace  
  > **username_0**: for JavaScriptFile attribute, we need to give path to the JSON file right?  Where should that file exist?  
  > **username_1**: @username_0 please see updated answer for steps on how you can try the different available configuration options to see what works for your situation.  
  > **username_0**: 1) Jenkins file: https://github.com/vineelyalamarthy/PriceAnalyzer/blob/master/Jenkinsfile#L11 and 2) my JSON file. 2)https://github.com/vineelyalamarthy/PriceAnalyzer/blob/master/test_data.json   This combination didn't seem to work.  
  > **username_1**: Can you post the error?  
  > **username_0**: No error. on the UI only name "SAMPLE_EXTENDED_CHOICE'" gets shown and nothing else. Let me go to the Jenkins UI and see if there are any errors.  
  > **username_0**: ERROR log : https://gist.github.com/vineelyalamarthy/f291d53e47feda75ea58988aefc24314  
  > **username_1**: Acoording to the third answer in this post: https://stackoverflow.com/questions/48041687/jenkins-fetching-the-value-of-a-json-extended-choice-parameter, it looks like you can use the Groovy Script option to return a JSON object, which also appears to be the case in the plugin's documentation (2nd pic): https://wiki.jenkins.io/display/JENKINS/Extended%20Choice%20Parameter%20plugin  
  > **username_0**: You mean Groovy script can can have the logic of reading the file and create a JSON object?  
  > **username_1**: That's one way. Another way could be directly accessing the source -- like whatever generates the values in your JSON file.  
  > **username_0**: Finally I tried this and still no luck.     extendedChoice (bindings: '', description: '', groovyClasspath: '', groovyScript: '''                 import org.boon.Boon;                 def data = new File('data_from_eric.json').getText('UTF-8');                 def jsonEditorOptions = Boon.fromJson('${data}');                 return jsonEditorOptions;                 ''', multiSelectDelimiter: ',', name: 'Policy12345', quoteValue: false, saveJSONParameterToFile: false, type: 'PT_JSON', visibleItemCount: 5)  
  
  ---
  
  