Hi - it would be really nice if the fileExists() step supported file globbing:

      if (fileExists('foo/bar*')) {
          // ... 
      }
      

      Currently the only way I can find to do this is an awkward use of the compgen command inside a try/catch, and this will only work on Unix:

      try {
          sh "compgen -G 'foo/bar*'"
          // ... 
      }
      catch (err) {
          pass
      }
      

          [JENKINS-38855] fileExists to support file globbing

          Jesse Glick added a comment -

          Will not implement in fileExists. Could be in the Utility Steps plugin. Generally if you find yourself needing things like this, consider moving all the logic into an external script.

          Jesse Glick added a comment - Will not implement in fileExists . Could be in the Utility Steps plugin. Generally if you find yourself needing things like this, consider moving all the logic into an external script.

          You may workaround this with findFiles from the Utility Steps plugin:

           

          if(findFiles([glob: 'foo/bar*']).size() > 0) {
              // ... 
          }

           

          Daniel Geißler added a comment - You may workaround this with findFiles from the Utility Steps plugin:   if (findFiles([glob: 'foo/bar*' ]).size() > 0) { // ... }  

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

              Created:
              Updated: