0

I want to execute JUnit Tests with Jenkins. And in one of the Tests I load a json file from src/test/resources.

Locally the test is working on windows (and mac). But jenkins says that the file is missing. So I checked it on the server, but this file was there.

I tried a "sudo chmod 775 -R "on the full workspace directory including subdirectories.

java.nio.file.NoSuchFileException: /var/lib/jenkins/workspace/a-project/java-framework/tests/junit/project-test/target/test-classes/testfolder/report.json

So I don't know how to solve it. Is it a Linux problem or is it about rights ? Maybe somebody has a tip. The only solution I know is to save the json as a String in the test class.

J. H
  • 102
  • 11
  • 1
    Didn't knew Jenkins is a "He"! possible duplicate https://stackoverflow.com/questions/33691950/why-jenkins-fails-to-load-the-resources – Milan Desai Apr 09 '19 at 15:38
  • 1
    @MilanDesai I found the solution on your URL, thank you very much! did you never check the image of Jenkins :P? It's a male butter :) – J. H Apr 09 '19 at 15:46

1 Answers1

1
URLDecoder.decode(getClass().getResource(fileName).getFile(), "UTF-8")

was the solution! Thank you Milan!

J. H
  • 102
  • 11