How do I check if a directory exists in a jenkins pipeline?

Viewed 297

I have this small pipeline stage that uses the script sh to check to see if a directory exists

        stage("Check if Module exists") {
            steps {
                script {
                    sh "ls -la && pwd"
                    sh "[ -d '"${env.SOURCE_REPO}"/"${env.COMPONENT_NAME}"' ]"
                    
                    repo_Check()
                }
            }
        }

Im using 2 env variables to create the full path of a directory. What is the correct syntax for this statement?

0 Answers
Related