title: How to get the absolute path of a file (from workspace) in Jenkins pipeline script (in windows environment)
body: <p><strong>How to get the absolute path of a file (from workspace) in Jenkins pipeline script (in windows environment)</strong></p>
  
  <p><strong>File locations</strong> (The files are checked-out from Git and Jenkinsfile2.nprd will have the groovy pipeline script):</p>
  
  <p>C:/Program Files (x86)/Jenkins/workspace/dev-my-api/my-data-api/my-data-api/pom.xml
  C:/Program Files (x86)/Jenkins/workspace/dev-my-api/my-data-api/Jenkinsfile2.nprd</p>
  
  <p><strong>Script:</strong></p>
  
  <pre><code> stages {
          stage('Setup')  {
              steps {
                  script {
                    pomPath = findFiles(glob: "**/pom.xml")[0].path
                    env.WORKSPACE = pwd()
                    pomDir = bat(script: "for %%F in ($pomPath) do set dirname=%%~dpF", returnStdout: true).trim()
                    echo "env.WORKSPACE:" + env.WORKSPACE
                    echo "pom file path:" + pomPath
                    echo "pom directory****:" + pomDir
                  }
              }
          }
  }
  </code></pre>
  
  <p><strong>Output:</strong></p>
  
  <pre><code>env.WORKSPACE:C:\Program Files (x86)\Jenkins\workspace\dev-my-api
  pom file path:my-data-api\pom.xml
  pom directory****:C:\Program Files (x86)\Jenkins\workspace\my-data-api&gt;for %F in (my-data-api\pom.xml) do set dirname=%~dpF 
  </code></pre>
  
  <p><strong>Requried path:</strong>  </p>
  
  <p>C:/Program Files (x86)/Jenkins/workspace/dev-my-api/my-data-api</p>
  
  <p>How to get the above required path in Jenkins pipeline script without hard coding?</p>