Groovy : How to give absolute file path of file.
SOLVED- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Groovy : How to give absolute file path of file.
Hi
I want to give absolute file path in Groovy. I have following code.
// Option 1 : this works on my local. but not on Jenkins/maven which is on server. As there is relative path of my local
request = xmlParser.parse("/home/vishalpachpute/API/Responses/Response_SelfFullTrans.xml")
// Option 2 : This works only in Maven/jenkins. Not in Ready API tool. In Ready API tool, It shows java.io.FileNotFoundException: /opt/SmartBear/ReadyAPI-1.9.0/bin/Responses/Response_SelfFullTrans.xml
request = xmlParser.parse("Responses/Response_SelfFullTrans.xml")
So can you please suggest any such absolute path so that it will work on both SOAP UI tool and Maven.
Kindly help me on this. Thanks in advance.
Regards
Vishal
Solved! Go to Solution.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In the script:
def prefix = context.expand('${#Project#BASE_DIRECTORY}')
def request = new File("${prefix}/API/Responses/Response_SelfFullTrans.xml").text
Regards,
Rao.
