title: Declarative Pipeline using env var as choice parameter value
body: <p>Disclaimer: I can achieve the behavior I’m looking for with Active Choices plugin, BUT I really want this to work in a Jenkinsfile and controlled with scm because it’s tedious to configure the Active Choices on each job we may need them on. And with it being separate from the Jenkinsfile creation, it’s then one job defined in multiple places. :(</p>
  <p>I am looking to verify <em><strong>if this is possible</strong></em>, because I can’t get the syntax right, if it is possible. And I haven’t been able to find any examples online:</p>
  <pre><code>pipeline {
      environment { 
          ARTIFACTS = lib.myfunc() // this works well
      }
      parameters {
          choice(name: &quot;Artifacts&quot;, choices: ARTIFACTS) // I can’t get this to work
      }
  }
  </code></pre>
  <p>I cannot use the function inline in the declaration of the parameter. The errors were clear about that, but it seems as though I should be able to do what I’ve written out above.</p>
  <p>I am not home, so I do not have the exceptions handy, but I will add them soon. They did not seem very helpful while I was working on this yesterday.</p>
  <p>What have I tried?</p>
  <p>I’ve tried having the the function return a List Because it requires a list according to the docs, and I’ve also tried (illogically) returning a String in the precise syntax of a list of strings. (It was hacky, like <code>return &quot;['&quot; + artifacts.join(&quot;', '&quot;) + &quot;']&quot;</code> to look like <code>['artifact1.zip', 'artifact2.zip']</code></p>
  <p>I also tried things like <code>&quot;$ARTIFACTS&quot;</code> and <code>${ARTIFACTS}</code> in desperation.</p>