0

One more time i come here for help. I will try to explain the best way i can.

When we run one pipeline if some test Failed the Stage View do not show the specific stage had failed. Only puts the Build has unstable.

So i check some post about it here like this one [https://stackoverflow.com/questions/36852310/show-a-jenkins-pipeline-stage-as-failed-without-failing-the-whole-job]

I try the solution: catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE'). But still keep's showing like this:

enter image description here

If i force the "sh "exit 1", just to check if it works, it present the fail:

enter image description here

So it´s seems that we have to pass the result from the UFT Test and so the Stage presents the same result.

This is the pipeline from build 7 that i run, "TESTE 2 QUE FALHA" is the test that i know that will fail from UFT, and teste 3 it's to make sure that the Pipeline dont stop and keep running stages to the end even if one or two stage fail.

Im probaly missing something or im not understanding the dinamic of this stage view.

Regards and Thx for any support.

    agent{
        label 'S-EA311601'
    }
    options {
        timeout(time: 60, unit: 'MINUTES')
    }
    stages{
        stage('1'){
            steps{
              bat 'del /S /Q "P:\\TA\\eBankaPlus\\R3G\\TRANSFERENCIAS\\001.Transferencia Interbancaria\\Report"'  
            }
        }
        stage('TEST 1'){
            steps{
                uftScenarioLoad archiveTestResultsMode: 'ONLY_ARCHIVE_FAILED_TESTS_REPORT', fsUftRunMode: 'Normal', testPaths: '''P:\\TA\\eBankaPlus\\R3G\\TRANSFERENCIAS\\001.Transferencia Interbancaria'''
            }
        }
        stage('2'){
            steps{
              bat 'del /S /Q "P:\\TA\\eBankaPlus\\R3G\\TRANSFERENCIAS\\004.Transferencia Conversao Divisas\\Report"'  
            }
        }
        stage('TESTE 2 QUE FALHA'){
            steps{
                uftScenarioLoad archiveTestResultsMode: 'ONLY_ARCHIVE_FAILED_TESTS_REPORT', fsUftRunMode: 'Normal', testPaths:  '''P:\\TA\\eBankaPlus\\R3G\\TRANSFERENCIAS\\004.Transferencia Conversao Divisas'''
                catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE'){
                }
            }
        }
        stage('3'){
            steps{
              bat 'del /S /Q "P:\\TA\\eBankaPlus\\R3G\\TRANSFERENCIAS\\002.Transferencia Interbancaria Outra Conta\\Report"'  
            }
        }
        stage('TESTE 3'){
            steps{
                uftScenarioLoad archiveTestResultsMode: 'ONLY_ARCHIVE_FAILED_TESTS_REPORT', fsUftRunMode: 'Normal', testPaths:  '''P:\\TA\\eBankaPlus\\R3G\\TRANSFERENCIAS\\002.Transferencia Interbancaria Outra Conta'''
            }
        }
    }
}

Rik
  • 105
  • 1
  • 6

1 Answers1

0

You might just have an typo in your steps...

try this:

        stage('TESTE 2 QUE FALHA'){
            steps{
                catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE'){
                    uftScenarioLoad archiveTestResultsMode: 'ONLY_ARCHIVE_FAILED_TESTS_REPORT', fsUftRunMode: 'Normal', testPaths:  '''P:\\TA\\eBankaPlus\\R3G\\TRANSFERENCIAS\\004.Transferencia Conversao Divisas'''
                }
            }
        }

Place the UFT action inside the catch error.

RichEdwards
  • 3,423
  • 2
  • 6
  • 22
  • Hi @RichEdwards,thank you for the help. I try what you said, but the stage keep showing green. It's wierd because the build ends has Unstable, so it detects that the test failed, but don't change the stage to Red and information of the failed. – Rik Jul 30 '20 at 14:55
  • To check - you want the stage view to return a fail? And your uft test is returning a fail but its not detected by the runner? – RichEdwards Jul 30 '20 at 15:26
  • Yes @RichEdwards, that's what we wanna do, so we can easly see what stage fail. What happens now its that the all pipeline stay like unstable, and we have to go stage by stage to detect which one failed. – Rik Aug 03 '20 at 08:27
  • Two thoughts spring to mind -> Do you have to execute the script or can you run a bit of VBS? - Create vbs that launches and manages the uft (qtp) object to run the test, after the run you can get the status of the run. i.e. if runStatus == failed, you can do sh exit 1 - second thought, call the exit 1 int he script. I assume you've got a framework? (and that framework isn't contaminating the fail result) so between steps or in the tear down log the test has failed then call an abnormal termination to force it to hard fail as you need... – RichEdwards Aug 03 '20 at 08:48