title: Extended Choice Parameter Groovy Script get Parameter Name in Value Field
body: <p>I have a groovy script that I use in the Extended Choice Parameter plugin to grab image names from artifactory. The image list it grabs is dependent on the name of the parameter.</p>
  
  <p>For example if we have two parameters, one called <code>test-repo</code> the other <code>dev-repo</code></p>
  
  <p>The groovy script would look something like this:</p>
  
  <pre><code>   @Grapes(
     @Grab(group='org.codehaus.groovy.modules.http-builder', module='http-builder', version='0.7.1')
  )
  
  import groovyx.net.http.RESTClient
  
  // the REPO_NAME below is test-repo or dev-repo depending on the parameter name
  def query = 'items.find({**&lt;REPO_NAME&gt;**}).limit(1)'
  
  def artifactoryURL = // the URL for artifactory
  
  def restClient = new RESTClient(artifactoryURL)
  restClient.setHeaders(['Authorization': 'Basic ' + "jenkins:password".getBytes('iso-8859-1').encodeBase64()])
  
  def response = restClient.post(
     path: 'artifactory/api/search/aql',
     body: query,
     requestContentType: 'text/plain'
     )
  
  response.getData().results.name
  </code></pre>
  
  <p>The problem is there are a lot of different repositories I need to reference and different artifactory URLs I might end up using.</p>
  
  <p>So I was trying to find a way that I can reference the parameter name to be able to use it in the parameter value.</p>
  
  <p>Something like this</p>
  
  <pre><code>def query = 'items.find({ params.key }).limit(1)'
  </code></pre>
  
  <p>Where <code>params.key</code> is the name of the parameter in this Extended Choice Parameter section.</p>
  
  <p>I have tried using different ways to reference the parameter name but they don't seem to work.</p>
  
  <p>I feel like I am trying to break the 4th wall by having a parameter value that references a parameter name prior to starting a build.</p>
  
  <p>I was thinking about somehow trying to grab the instance of the Jenkins build and try to look at the parameter name but any such effort proved useless. I also tried using <code>this</code> or <code>it</code> hoping that groovy would grab the current instance of the parameter so I can reference <code>this.name</code> or <code>it.name</code> but none of it works.</p>
  
  <p>EDIT (after hitting the 1,000 views mark): </p>
  
  <p>I never found the solution to this. Instead for every extended choice parameter I have hard coded the repository name I want to get the images from.</p>