title: Jenkinsfile multiline sh continue on error
body: <p>I want to do some Docker cleanup steps before a Jenkins build. This is the build step:</p>
  <pre><code>steps {
      script {
          try {
              sh '''
                  docker container stop  $(docker ps -q)
                  docker rm $(docker ps -aq)
                  docker  rmi -f $(docker images -q)
                  docker build -f Dockerfile_build | tee buildlog.txt
              '''
          } catch(err) {
              echo err.getMessage()
          }
      }
  }
  </code></pre>
  <p>The first lines of the <code>sh</code> part may fail, causing the whole build to fail:</p>
  <blockquote>
  <p>[Pipeline] sh <br />
  ++ docker ps -q <br />
  + docker container stop Error: you must provide at least one name or id<br />
  [Pipeline] echo <br />
  script returned exit code 125</p>
  </blockquote>
  <p>However, that only means that there's no cleanup to do. I want to continue the build job, no matter how many of the first three lines fail. My question is whether I have to put each of them in its own try/catch block, or if there's a more concise way of saying &quot;try these and ignore any errors&quot;.</p>