jenkinsci / jenkinsci/workflow-basic-steps-plugin

[JENKINS-38856] BasicStep - dirExists

Open
#410 1 comment 0 reactions 0 assignees View on GitHub
component:workflow-basic-steps-plugin imported-jira-issue priority:minor resolution:unresolved
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


  • status: Open
  • priority: Minor
  • component(s): workflow-basic-steps-plugin
  • resolution: Unresolved
  • votes: 0
  • watchers: 3
  • imported: 20251215-220547

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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.