Workspace and project path from script

PBelandPBeland Posts: 14

I need to access files saved to my workspace from Groovy script. How can I get the path to my workspace and project?

Comments

  • OmarROmarR Posts: 205 admin

    Hey PBeland!

    I did a quick search online and found the following:
    http://forums.parasoft.com/discussion/comment/7408#Comment_7408

  • PBelandPBeland Posts: 14

    Yeah, I found it too. I'd like to get a path relative to my workspace in case our test structure change. Until then, I can get to there with something like that:

    def projectDir = context.getAbsolutePathFile(".\\..\\..\\..\\MyWorkspace");
    Application.showMessage("Workspace location is ${projectDir}");
    

    Better than nothing ;)

    Thanks

  • Ramiro MartinezRamiro Martinez Posts: 47 admin

    Hi PBeland,

    Here is an example script that utilizes the methods that are mentioned in the link that Omar posted:

    from soaptest.api import *
    from com.parasoft.api import *
    from java.io import *
    
    def main(input, context):
    
        f = context.getAbsolutePathFile(".")
        Application.showMessage(f.getAbsolutePath())
        #returns absolute path to project folder  
    
        s = f.getAbsolutePath() + File.separator + "some.xml" 
        Application.showMessage(s)
    

    These API calls will return the path to the Project folder that contains the extension tool.

Sign In or Register to comment.