title: Jenkinsfile Pipeline errors: “expected a step” and “undefined section”
body: <p>Can anyone explain why I get the following errors, and what can be a possible solution for them?</p>
  
  <blockquote>
    <p>Running in Durability level: MAX_SURVIVABILITY
    org.codehaus.groovy.control.MultipleCompilationErrorsException:
    startup failed: WorkflowScript: 43: Expected a step @ line 43, column
    17.
                       if (isUnix()) {
                       ^</p>
    
    <p>WorkflowScript: 71: Undefined section "success" @ line 71, column 5.
           success {
           ^</p>
    
    <p>WorkflowScript: 78: Undefined section "failure" @ line 78, column 5.
           failure {
           ^</p>
    
    <p>WorkflowScript: 16: Tool type "maven" does not have an install of
    "MAVEN_HOME" configured - did you mean "Maven M2"? @ line 16, column
    19.
                   maven "MAVEN_HOME"
                         ^</p>
    
    <p>WorkflowScript: 17: Tool type "jdk" does not have an install of
    "JAVA_HOME" configured - did you mean "null"? @ line 17, column 17.
                   jdk "JAVA_HOME"
                       ^</p>
  </blockquote>
  
  <p>The code in the <code>Jenkinsfile</code> is as follows:</p>
  
  <pre class="lang-groovy prettyprint-override"><code>  pipeline {
  
          // agent defines where the pipeline will run.
          agent {
              // Here we define that we wish to run on the agent with the label SL202_win
              label "SL202_win"
          }
  
          // The tools directive allows you to automatically install tools configured in
          // Jenkins - note that it doesn't work inside Docker containers currently.
          tools {
              // Here we have pairs of tool symbols (not all tools have symbols, so if you
              // try to use one from a plugin you've got installed and get an error and the
              // tool isn't listed in the possible values, open a JIRA against that tool!)
              // and installations configured in your Jenkins master's tools configuration.
              maven "MAVEN_HOME"
              jdk "JAVA_HOME"
          }
  
          environment {
              // Environment variable identifiers need to be both valid bash variable
              // identifiers and valid Groovy variable identifiers. If you use an invalid
              // identifier, you'll get an error at validation time.
              // Right now, you can't do more complicated Groovy expressions or nesting of
              // other env vars in environment variable values, but that will be possible
              // when https://issues.jenkins-ci.org/browse/JENKINS-41748 is merged and
              // released.
              mvnHome = "D:/Tools/apache-maven-3.5.2"
          }
  
          stages {
              // At least one stage is required.
              stage("Preparation") {
                  // Every stage must have a steps block containing at least one step.
                  steps {
                      // Get some code from a GitHub repository
                      git 'https://git.ceesiesdomain.nl/scm/rsd/test_automation.git'
                  }
              }
              stage('Build') {
                  steps {
                  // Run the maven build
                  if (isUnix()) {
                      sh "'${mvnHome}/bin/mvn' clean test -Dtest=TestRunner"
                  } else {
                      bat(/"${mvnHome}\bin\mvn" clean test -Dtest=TestRunner/)
                  }
              }
          }
              stage('Results') {
              steps {
                  cucumber buildStatus: 'UNSTABLE', failedFeaturesNumber: 999, failedScenariosNumber: 999, failedStepsNumber: 3, fileIncludePattern: '**/*.json', skippedStepsNumber: 999
              }
          }
      }
          // Post can be used both on individual stages and for the entire build.
          post {
              success {
                  echo "Test run completed succesfully."
              }
              failure {
                  echo "Test run failed."
              }
              always {
          // Let's wipe out the workspace before we finish!
                  deleteDir()
                  echo "Workspace cleaned"
              }
      }
  
      success {
          mail(from: "jenkins@ceesiesdomain.nl",
                  to: "ceesie@ceesiesdomain.nl",
                  subject: "That build passed.",
                  body: "Nothing to see here")
      }
  
      failure {
          mail(from: "jenkins@ceesiesdomain.nl",
                  to: "ceesie@ceesiesdomain.nl",
                  subject: "That build failed!",
                  body: "Nothing to see here")
      }
  
      // The options directive is for configuration that applies to the whole job.
      options {
          // For example, we'd like to make sure we only keep 10 builds at a time, so
          // we don't fill up our storage!
          buildDiscarder(logRotator(numToKeepStr:'10'))
  
          // And we'd really like to be sure that this build doesn't hang forever, so
          // let's time it out after an hour.
          timeout(time: 60, unit: 'MINUTES')
      }
  }
  </code></pre>