2018-08-07

Jenkins pipeline calls cmd command

When you need to call cmd command from Jenkins pipeline script you can do it in following way. I am just storing that piece of code here.
steps
  {  
   script
    {
     env.GitCurrentHash=bat(returnStdout: true, script: "@echo off | git --git-dir=${WORKSPACE}\\.git rev-parse origin/${branch}").trim()
    }
  
echo "Current Git Hash: ${GitCurrentHash}"
   echo "Current Git Hash: ${GIT_COMMIT}"
  }
That's all...