Skip to content
Advertisement

dot dot(..) pathing doesnt work on java new file with linux running jenkins

 File f = new File(basedir, "../src/main");

I have this in a maven build on Jenkins. It’s being used to generate files. It works when building on my local machine(windows 7) but doesn’t work when i run it on Linux. It looks like it’s taking the .. as a literal folder path and not going back a directory. The error is:

 Embedded error: /path/to/Jenkins/project/target/../src/main/xsd/common.xsd (No such file or directory)

Advertisement

Answer

Using basedir.getParent() works.

Advertisement