fileExists doesn't take variables

XMLWordPrintable

    • Type: Bug
    • Resolution: Not A Defect
    • Priority: Critical
    • None
    • Environment:
      Linux Ubuntu

      I created a pipeline job with a Jenkins files that has the following content.. but I can't get controlFile to work correctly as it is a variable and fileExists doesnt seem to resolve it.

      node {
      def controlFile = '/path/somefile.txt'
      if (fileExists(controlFile)) {
      echo '${controlFile} exists.'
      } else {
      echo '${controlFile} missing. Will try to mount'
      sh 'mount /path/server/extFs'
      if (fileExists(controlFile)) {
      echo '${controlFile} exists after mount. Continue...'
      } else {
      error: '${controlFile} still missing. Will now fail the job.'
      }
      }
      }

            Assignee:
            Rachel M.
            Reporter:
            angel vera
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: