title: JenkinsFile how to query if job exists
body: <p>In a declarative Jenkinsfile how can you determine if a job exists?</p>
  
  <p>I want to conditionally run a stage if another job exists, like so:</p>
  
  <pre><code>pipeline {
    agent { label 'mylabel' }
    // Run the the stages:
    stages {
      stage('Pre-Build') {
        steps {
          timestamps { ansiColor('xterm') { sh 'build/jenkins_prebuild.sh' } }
        }
      }
      stage('Pre-Build') {
        steps {
          timestamps { ansiColor('xterm') { sh 'build/jenkins_build.sh' } }
        }
      }
      stage('Trigger Remote If Exists'){
      when { JOB_EXISTS }
        steps {
          timestamps {
            ansiColor('xterm') {
              sh 'build/pre-trigger.sh'
              build job: "../myjob/foo", wait: false, parameters: [booleanParam(name: 'FOO', value: true)]
            }
          }
        }
      }
    }
  }
  </code></pre>
  
  <p>Basically, what should I do for JOB_EXISTS?</p>