title: Jenkins Pipeline Job with Condition
body: <p>I am creating a Jenkins pipeline. This pipeline is building three jobs (JobOne, JobTwo, JobThree). I am able to run the job with following code.</p>
  
  <pre><code>node {
     stage 'Stage 1'
     echo 'Hello World 1'
     build 'Pipeline-Test/JobOne'
  
     stage 'Stage 2'
     echo 'Hello World 2'
     build 'Pipeline-Test/JobTwo'
  
     stage 'Stage 3'
     echo 'Hello World 3'
     build 'Pipeline-Test/JobThree'
  }
  </code></pre>
  
  <p>Now I want to put some condition in it. Example, when JobOne fails, the job has to restart once again. When JobTwo passes, want to run job again. And JobThree should run after a span of 10 mins after JobTwo completes. I am not sure how to make pipeline with this condition. I am new to Jenkins pipeline.</p>
  
  <p>I checked few Jenkins WiKi page but could not find a proper way to implement if condition with above conditions. I tried below code just to check how 'if' condition can be implemented. But it fails.</p>
  
  <pre><code>node {
     stage 'Stage 1'
     echo 'Hello World 1'
     build 'Pipeline-Test/JobOne'
     post {
         always{
             build 'Pipeline-Test/JobOne'
         }
     }
  </code></pre>
  
  <p>Error:</p>
  
  <pre><code>java.lang.NoSuchMethodError: No such DSL method 'post' found among [archive, bat, build, catchError, checkout, checkpoint, deleteDir, dir, dockerFingerprintFrom, dockerFingerprintRun, echo, error, fileExists, git, input, isUnix, load, mail, node, parallel, properties, publishHTML, pwd, readFile, retry, sh, sleep, sshagent, stage, stash, step, teamconcert, timeout, tool, triggerRemoteJob, unarchive, unstash, waitUntil, withCredentials, withDockerContainer, withDockerRegistry, withDockerServer, withEnv, wrap, writeFile, ws]
      at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:107)
  </code></pre>
  
  <p>Can someone please guide me through this?</p>
  
  <p>Thanks in advance!</p>