Your browser was unable to load all of the resources. They may have been blocked by your firewall, proxy or browser configuration.
Press Ctrl+F5 or Ctrl+Shift+R to have your browser try again.

Change groovy scripts working directory #3891

salamay ·

I want to execute a groovy script step inside a subdirectory of a configs working directory. How can i do this? for the buildscript step I see options to provide the build scritp path which can be different that the working directory. I want to do something like that with Execute Script step.

  • replies 3
  • views 2549
  • stars 0
robinshen ADMIN ·

There is no working directory concept for groovy script execution. However you can always refer to sub directory under workspace directory this way:
new File(configuration.workspaceDir, "subdir")

salamay ·

This is what i wanna do

groovy:
def sRootDir = configuration.workspaceDir.absolutePath + '/' + vars.getValue("ProjectPath") + '/TestScripts/';
def sPythonExe = configuration.workspaceDir.absolutePath + '/' + vars.getValue("ProjectPath") + '/Tools/Python/python.exe';
def generateScriptCmd = '"' + sPythonExe + '" GenerateScript.py';
def proc1 = generateScriptCmd.execute();
proc1.waitFor();

I want generateScriptCmd to be executed inside sRootDir and not configuration.workspaceDir.absolutePath. If this was a batch script i would use pushd and popd but i dont know how to do it in a groovy script.

salamay ·

ok i was able to get it to work doing so

def proc1 = generateScriptCmd.execute(null, new File(sRootDir));