Issue
I am very new to Groovy and Jenkins. I am trying to check if file exists on generalize path something like this:
when {
expression { return (fileExists("*service/target/test-classes") }
}
In my path, I have generalized path like app-study-service
or app-share-service
, then I create target folder with test-classes folder.
I want Jenkins to trigger steps step after this when condition if there is file in that path. How can I achieve this?
Solution
I found why it wasn't working. It is because fileExists does not support wildcards. I would need to use without wildcard or use something that supports wildcards, such as findFiles.
Jenkins pipeline to verify files existence in specific format inside when condition
Answered By - Jonathan Hagen