Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins pipeline to verify files existence in specific format inside when condition

I need to verify whether any file exists in .doc format in a specific directory. based on which when the condition will be executed.

i.e) when a file found inside a directory with the .doc extension it should proceed to execute steps.

Below code is unable to find the files in .doc format

        when {
            expression
            { 
               return (fileExists("""${Path}/${version}/test/*.doc"""))
            }
        }
like image 742
TryandCatch Avatar asked Oct 19 '25 06:10

TryandCatch


1 Answers

Use findFiles, fileExists doesn't support wildcards.

when {
    expression { 
       return (findFiles(glob: "${Path}/${version}/test/*.doc").length > 0)
    }
}
like image 84
hakamairi Avatar answered Oct 22 '25 03:10

hakamairi