title: Passing Jenkins environment variable in Powershell script
body: <p>i would like to use a jenkins environment variable inside a power shell script.Here ${destination} is coming as null inside powershell script.Not able to identify what is the mistake i am doing.Please help</p>
  <pre><code># !/bin/groovy
  pipeline {
      
      agent {
          label {
              label &quot;&quot;
              customWorkspace &quot;C:\\Jenkins\\workspace&quot;
          }
      }
      environment {       
          
          def destination=''
      }
      options {
          timestamps()
          timeout(time: 60, unit: 'MINUTES')      
          skipDefaultCheckout(true)
          disableConcurrentBuilds()
       }
      
      stages {
          
          stage('TEST') 
          {     
              steps {
                      script{
                          destination=&quot;\\\\SERVERNAME\\d\$&quot;
                      }
                      echo &quot;${destination}&quot;
                      
                      powershell '''
                      
                          $destinationPath =&quot;${destination}&quot;
                           
                          write-host $destinationPath
                          
                          write-host &quot;test3&quot; '''
                      
                  }  
          }
      }
      post {
          always {
              deleteDir()         
          }   
  }
  </code></pre>