Answers: <p>You can use <code>params['IP Address']</code>.</p>
  
  <p>Think of <code>params</code> as a Map containing a key <code>'IP Address'</code>. If the key didn't have a space, then you could use <code>params.IPAddress</code> or <code>params['IPAddress']</code>, but when there's a space, you can only use the latter syntax.</p>
  
  <p>That syntax is also useful when you're computing the key name to look up, and have stored it in a variable:</p>
  
  <pre><code>final String myParam = "param${i}"
  // can't say `params.myParam`
  echo "Value is ${params[myParam]}"
  </code></pre>
  
Answers: CC BY-SA 4.0
Answers: 2021-02-09T10:28:24.230Z
Answers: This doesn't work for me. In my declarative pipeline (Jenkinsfile) I've tried to do a `when` clause like this: `when { expression { params['Force generate NuGet'] == "true" } }`, but when I run my job and provide a parameter value, it doesn't pick up the value I gave it. Are there any pitfalls I should be aware of, any things I might be doing wrong?
Answers: Claus Appel
Answers: CC BY-SA 4.0
Answers: 2018-08-07T14:43:14.077Z
Answers: 2018-08-07T14:43:14.077Z
Answers: grdryn
Body: <p>Google has failed to even lead me to a proper answer as to why spaces are permitted in names of Jenkins parameters, let alone how to reference them. Assuming it's not just a major oversight, how does one access these parameters?</p>
  
  <p>For example, I have a string parameter named "IP Address". I could rename it "IP_Address" but I'm trying to avoid the underscores_as_spaces if I can. </p>
  
  <p>I've tried to refer to this parameter using "${IP Address}", "IP Address" and even "IP\ Address" but nothing seems to work. Is there any way to actually reference these?</p>
  
Tags: <jenkins><jenkins-pipeline>
Title: In Jenkins, how can parameters that contain spaces be referenced?
UserDisplayName: Argyle
ThreadText: # In Jenkins, how can parameters that contain spaces be referenced?
  
  (Asked by: username_0 on 2018-08-07)
  
  Google has failed to even lead me to a proper answer as to why spaces are permitted in names of Jenkins parameters, let alone how to reference them. Assuming it's not just a major oversight, how does one access these parameters?
  
  For example, I have a string parameter named "IP Address". I could rename it "IP\_Address" but I'm trying to avoid the underscores\_as\_spaces if I can.
  
  I've tried to refer to this parameter using "${IP Address}", "IP Address" and even "IP\ Address" but nothing seems to work. Is there any way to actually reference these?
  
  **Tags:** jenkins, jenkins-pipeline
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-08-07. Score: 5 | Accepted answer
  
  You can use `params['IP Address']`.
  
  Think of `params` as a Map containing a key `'IP Address'`. If the key didn't have a space, then you could use `params.IPAddress` or `params['IPAddress']`, but when there's a space, you can only use the latter syntax.
  
  That syntax is also useful when you're computing the key name to look up, and have stored it in a variable:
  
  ```
  final String myParam = "param${i}"
  // can't say `params.myParam`
  echo "Value is ${params[myParam]}"
  
  ```
  
  > **Comments:**
  > **username_2**: This doesn't work for me. In my declarative pipeline (Jenkinsfile) I've tried to do a `when` clause like this: `when { expression { params['Force generate NuGet'] == "true" } }`, but when I run my job and provide a parameter value, it doesn't pick up the value I gave it. Are there any pitfalls I should be aware of, any things I might be doing wrong?  
  
  ---
  
  