getResource() returns null when run code in gitlab pipeline and target directory is empty

Viewed 22

I have an empty folder emptyFolder. When I run code locally (gradle) it works

this.getClass().getClassLoader().getResource(emptyFolder)

But when I run the same code in gitlab pipeline it returns null

All tasks before the running are the same

> Task :compileJava NO-SOURCE
> Task :processResources NO-SOURCE
> Task :classes UP-TO-DATE
> Task :cleanTest
> Task :compileTestJava UP-TO-DATE
> Task :processTestResources UP-TO-DATE
> Task :testClasses UP-TO-DATE
> Task :test

At the same time if I put any file in emptyFolder it works in gitlab pipeline as well. Looks like the issue happens when I use getResource() for empty directory only. But why I do not have the same issue during the local running? Could somebody help me to understand?

1 Answers

Is the directory created in the pipeline? Git does not track empty directories so it could be caused by that empty directory exists on local computer but is never created on the machine where pipeline is running.

Related