fileExists doesn't take variables

This issue is archived. You can view it, but you can't modify it. Learn more

XMLWordPrintable

      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
            Archiver:
            Jenkins Service Account

              Created:
              Updated:
              Resolved:
              Archived: