Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

Workspace and project path from script

PBeland
PBeland 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

  • OmarR
    OmarR Posts: 231 admin

    Hey PBeland!

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

  • PBeland
    PBeland 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 Martinez
    Ramiro Martinez Posts: 53 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.