2

I am trying to check if abcd.png exists inside the flows folder

flows/abcd.png

so in groovy I am doing this

def file = new File("flows/abcd.png").exists()

but it is returning false. When I do ls I can see the file exists inside the flows folder as well. What am I doing wrong? Any help would be appreciated

Also I tried with

"/flows/abcd.png"
".flows/abcd.png"
"./flows/abcd.png"

But it gives false for all the cases

Cyrus
  • 84,225
  • 14
  • 89
  • 153
Saurav Dutta
  • 157
  • 3
  • 9
  • 6
    Debug/print your current working directory inside your groovy script (https://stackoverflow.com/questions/4871051/how-to-get-the-current-working-directory-in-java); your code there is correct - most likely you are not running it from where you think you are running it. – cfrick May 22 '20 at 09:55

1 Answers1

0

you could use fileExists(), to check the existence of the file

if (fileExists("${workspace}/flows/abcd.png")) { do_something }

d_k
  • 11
  • 3