TryandCatch
TryandCatch

Reputation: 285

Jenkins pipeline to verify multpile file existence in when condition

I need to verify multiple file existence in single when condition using && operation. check for any file that ends with .doc along with final.txt and proceed further. Second fileexistence(final.txt) seems to be working fine seperately. Please suggest on this

        when {
            expression
            { 
               return (fileExists("""ls ${Path}/${version}/test/*.doc""")) && !(fileExists("""${Path}/${Version}/test2/final.txt"""))
            }
        }

Upvotes: 1

Views: 793

Answers (1)

hakamairi
hakamairi

Reputation: 4678

You could use allOf and not

when {
     allOf {
        expression { 
            return fileExists("ls ${Path}/${version}/test/*.doc") 
        }
        not {
            expression {
                return fileExists("${Path}/${Version}/test2/final.txt")
            }
        }
    }
}

Upvotes: 2

Related Questions