Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-38972

fileExists doesn't take variables

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not A Defect
    • Icon: Critical Critical
    • None
    • 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.'
      }
      }
      }

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

              Created:
              Updated:
              Resolved: