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

try-catch is not working in declarative pipeline

XMLWordPrintable

      pipeline {
        stages {
          stage("Test") {
            script {
              for (i in list){
                  try {
                    echo "Any code with error"
                  } catch(err) {
                    echo "Error"
                  }
              }
            }
          }
        }
      }
      

       

      So the try-catch is not working in script section of declarative pipeline. It throws an exception and pipeline fails

            Unassigned Unassigned
            slavik334 Viachaslau Kabak
            Votes:
            4 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: