title: Jenkins declarative pipeline dynamic choice parameter doesn't get updated after first build
body: <p>I'm trying to convert old Jenkins jobs to declarative pipeline code.</p>
  
  <p>When trying to use the choice parameter in the script I implement a function which should return updated values, if the values are not the most recent ones - the job will fail. </p>
  
  <p>The problem is that after the first build which looks ok, the values stay static, they don't get updated afterwards which as I said above - fails my job.
  It's like the function that i wrote runs only one time at the first build and doesn't run ever again.</p>
  
  <p>I've tried writing the code in a way that the output will be sent to a file and be read from it - thus maybe the function will get updated by getting the text from a file - that didn't work.</p>
  
  <p>I've tried looking at the Jenkins documentation / a lot of other threads and didn't find a thing.</p>
  
  <p>My code looks like this:</p>
  
  <pre><code>def GetNames() {
      def workspace = "..."
      def proc = "${workspace}/script.sh list".execute()
      return proc.text
  }
  </code></pre>
  
  <p><strong>${workspace}</strong> - Is just my workspace, doesn't matter.</p>
  
  <p><strong>script.sh</strong> - A script that 100% works and tested</p>
  
  <p><strong>return proc.text</strong> - Does return the values, I've tested it in my Jenkins website/script section and the values do return properly and updated.</p>
  
  <p>My parameters section:</p>
  
  <pre><code>parameters {
      choice(name: 'Names', choices: GetNames(), description: 'The names')
  }
  </code></pre>
  
  <p>First build I get 5 names, which is good because those are the updated values, seconds build I know there are 10 values but I still get the 5 from before, and every build after that I will still get the same 5 names - they do not get updated at all, the function does not get triggered again.</p>
  
  <p>It seems like this is a very long running issue which still didn't get patched, the only thread that had this mentioned was this one:
  <a href="https://stackoverflow.com/questions/44570163/jenkins-dynamic-declarative-pipeline-parameters">Jenkins dynamic declarative pipeline parameters</a> but the solution is in a scripted and not declarative way.</p>