jenkinsci / jenkinsci/workflow-basic-steps-plugin
[JENKINS-38856] BasicStep - dirExists
- Dominant language
- Java
- Stars
- 73
- Forks
- 129
- PR merge metrics
- No merged PRs in 30d
Description
Hi, it would be really nice if there was a dirExists() function that worked like fileExists()
Currently the only way to do this is to use a complicated subshell which clutters up the logs:
def dirExists(path) {
def exists = sh returnStdout: true, script: """path=\$(compgen -G \"${path}\") || true
if [ ! -z \"\$path\" -a -d \"\$path\" ]; then
echo true
else
echo false
fi
"""
return (exists == 'true')
}
---
Originally reported by eeaston, imported from: BasicStep - dirExists
Raw content of original issue
Hi, it would be really nice if there was a dirExists() function that worked like fileExists()
Currently the only way to do this is to use a complicated subshell which clutters up the logs:
def dirExists(path) {
def exists = sh returnStdout: true, script: """path=\$(compgen -G \"${path}\") || true
if [ ! -z \"\$path\" -a -d \"\$path\" ]; then
echo true
else
echo false
fi
"""
return (exists == 'true')
}
Contributor guide
Assessment
This issue has not been assessed yet.