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')
      }
      

          [JENKINS-38856] BasicStep - dirExists

          Jesse Glick added a comment -

          Probably simpler (untested):

          def dirExists(path) {sh(script: "[ -d '${path}' ]", returnStatus: true) == 0}
          

          Jesse Glick added a comment - Probably simpler (untested): def dirExists(path) {sh(script: "[ -d '${path}' ]" , returnStatus: true ) == 0}

            Unassigned Unassigned
            eeaston Edward Easton
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: