How do I continue to build Jenkins, even if the build step failed?

I am using the Phing script assembly with Jenkins and would like to run it to the end on a task and capture all reports. The problem is that it stops at the failed build stage. Is there a way or plugin that will continue to work even if it crashes?

thank

+3
source share
2 answers

I don’t know much about Phing, but since it is based on Ant, if the build step you are executing has the attribute “failonerror”, you must set it to false so that the whole build fails, if the step returns an error .

+1
source

Yes, use try, catch block in pipeline scripts

Example:

try {
    // do some stuff that potentially fails
} catch (error) {
    // do stuff if try fails
} finally {
    // when you need some clean up to do
}

, sh , sh ​​ "|| true", linux sh script 0, .

:

stage('Test') {
    def testScript = ""
    def testProjects = findFiles(glob: 'test/**/project.json')

    if (!fileExists('reports/xml')) {
        if (!fileExists('reports')) {
            sh "mkdir reports"
        }
        sh "mkdir reports/xml"
    }

    for(prj in testProjects) {
        println "Test project located, running tests: " + prj.path
        def matcher = prj.path =~ 'test\\/(.+)\\/project.json'

        testScript += "dotnet test --no-build '${prj.path}' -xml 'reports/xml/${matcher[0][1]}.Results.xml' || true\n"
    }

    sh testScript
0

All Articles