Try-catch block in Jenkins pipeline script

后端 未结 5 1676
有刺的猬
有刺的猬 2020-12-13 18:16

I\'m trying to use the following code to execute builds, and in the end, execute post build actions when builds were successful. Still, I get a MultipleCompilationErrorsExce

5条回答
  •  执念已碎
    2020-12-13 18:54

    This answer worked for me:

    pipeline {
      agent any
      stages {
        stage("Run unit tests"){
          steps {
            script {
              try {
                sh  '''
                  # Run unit tests without capturing stdout or logs, generates cobetura reports
                  cd ./python
                  nosetests3 --with-xcoverage --nocapture --with-xunit --nologcapture --cover-package=application
                  cd ..
                  '''
              } finally {
                junit 'nosetests.xml'
              }
            }
          }
        }
        stage ('Speak') {
          steps{
            echo "Hello, CONDITIONAL"
          }
        }
      }
    }
    

提交回复
热议问题