title: How to run a TestNG.xml through a Shell Script in Jenkins?
body: <p><strong>First Step</strong>: I created a BAT File with below mentioned commands and tried running it > It did successfully run the TestNG Suite with all the tests I had configured. </p>
  
  <p><strong>Next Step</strong>: was to set up the Jenkins I was trying to run the bat file with the Add build setup > execute Windows bat command > </p>
  
  <pre><code>cd /d %~dp0
  
  set classpath=bin;lib\*;lib\selenium\*;lib\POI\*;bin\com\healthcare\*;bin\com\healthcare\reports\*;
  
  java org.testng.TestNG Smoke_OrderIDCards.xml
  </code></pre>
  
  <p>And also </p>
  
  <p><code>run smoke.bat</code> which has all the above commands</p>
  
  <p>And also with</p>
  
  <pre><code>call %WORKSPACE%\smoke.bat
  </code></pre>
  
  <p>and also</p>
  
  <pre><code>run %WORKSPACE%\smoke.bat
  </code></pre>
  
  <p>it kept throwing the error in Jenkins console as: </p>
  
  <pre><code>[Purchaser] $ cmd /c call /proj/jenkins/tmp/jenkins9142107435735320094.bat
  FATAL: command execution failed
  java.io.IOException: error=2, No such file or directory
      at java.lang.UNIXProcess.forkAndExec(Native Method)
      at java.lang.UNIXProcess.&lt;init&gt;(UNIXProcess.java:248)
      at java.lang.ProcessImpl.start(ProcessImpl.java:134)
      at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
  Caused: java.io.IOException: Cannot run program "cmd" (in directory "/proj/jenkins/workspace/Purchaser"): error=2, No such file or directory
      at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
      at hudson.Proc$LocalProc.&lt;init&gt;(Proc.java:245)
      at hudson.Proc$LocalProc.&lt;init&gt;(Proc.java:214)
      at hudson.Launcher$LocalLauncher.launch(Launcher.java:850)
      at hudson.Launcher$ProcStarter.start(Launcher.java:384)
      at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:109)
      at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:66)
      at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
      at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:735)
      at hudson.model.Build$BuildExecution.build(Build.java:206)
      at hudson.model.Build$BuildExecution.doRun(Build.java:163)
      at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:490)
      at hudson.model.Run.execute(Run.java:1735)
      at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
      at hudson.model.ResourceController.execute(ResourceController.java:97)
      at hudson.model.Executor.run(Executor.java:405)
  Build step 'Execute Windows batch command' marked build as failure
  Finished: FAILURE
  </code></pre>
  
  <p>But I figured what if the server it's running on, is not Windows and tried running a sample command through <code>Add Build Step &gt; Execute Shell</code></p>
  
  <p>with the command as <code>echo $WORKSPACE</code> and that was a success. And I tried looking up everywhere I could to finout how to do the same through shell script and was not able to.</p>
  
  <p>Now I need to know how to run the same commands I mentioned above <code>(set classpath and run the TestNG.xml file)</code> through shell commands. Could someone help me with this problem?</p>