everybody, I have a problem with a stage in a Declaritive pipeline in Jenkins. I'd like Jenkins to check if the directory /root/elp contains data with the name *.php If this is the case, jenkins should execute a command. If there is nothing in the folder, Jenkins should finish the job with success.
My Code that not function :
stage('Test Stage') { steps { script { def folder = new File( '/root/elp/test.php' ) if( folder.exists() ) { sh "LINUX SHELL COMMAND" } else { println "File doesn't exist" } } }