title: How to use environment variable inside Jenkinsfile
body: <p>I am having similar issue as mentioned here:
  <a href="https://stackoverflow.com/questions/43879733/jenkinsfile-declarative-pipeline-defining-dynamic-env-vars/43881731">Jenkinsfile Declarative Pipeline defining dynamic env vars</a></p>
  
  <p>I am trying to deploy an application via jenkinsfile. For which I have to run this command on the deploy stage in Jenkins (if I hardcode the value then it works fine):</p>
  
  <pre><code>xldDeploy serverCredentials: 'usernam', environmentId: 'Environments/SysTest1/SysTest1_1', packageId: 'Applications/Testapp/testapp_1.0.4.5.Build39_TAG-test'
  </code></pre>
  
  <p>"testapp_1.0.4.5.Build39_TAG-test" is getting generated at running time. Which can be created by concating <code>"${TagVersion}.Build${env.BUILD_NUMBER}_${ComponentTagName}"</code>
  I tried below code in my jenkins pipeline:</p>
  
  <pre><code>stage('Deploy') {  
     node('noibuild01') {
      if ("${env.Build_WildflyCPECommon}" == 'true') {
      echo "${TagVersion}"
      echo "${ComponentTagName}"
      echo "${env.BUILD_NUMBER}"
      script {
                      env.buildNumber = "${TagVersion}.Build${env.BUILD_NUMBER}_${ComponentTagName}"
                      env.packageid = "'Applications/Testapp/${env.buildNumber}'"
                  }
      echo "${env.buildNumber}"
      echo "${env.packageid}"
  
      xldDeploy serverCredentials: 'nex8voo', environmentId: 'Environments/SysTest1/SysTest1_1', packageId: "${env.packageid}"
      }
      }
    }
  </code></pre>
  
  <p>I checked the output, it is showing correctly:</p>
  
  <pre><code>echo "${env.buildNumber}" giving
  testapp_1.0.4.5.Build39_TAG-test
  echo "${env.packageid}" giving 
  'Applications/Testapp/testapp_1.0.4.5.Build39_TAG-test'
  </code></pre>
  
  <p>But <code>xldDeploy serverCredentials: 'username', environmentId: 'Environments/SysTest1/SysTest1_1', packageId: "${env.packageid}"</code>
  is taking as 
   [/repository/ci/'Applications/Testapp/testapp_1.0.4.5.Build39_TAG-test']: Repository entity ['Applications/Testapp/testapp_1.0.4.5.Build39_TAG-test'] not found</p>
  
  <p>I think I can't use <code>packageId: "${env.packageid}"</code>.</p>
  
  <p>Is there anything I could try? Maybe Groovy or Python code?</p>