简体   繁体   中英

Azure devops pipeline job shows success even though the Maven task is failed

I'm getting "Build Success" in the log of Maven task even though the goal task is failure. How to make the job a failure if the task has errors as below? Thanks.

Yaml file:

    - task: Maven@3
  inputs:
    mavenPomFile: 'pom.xml'
    mavenOptions: '-Xmx3072m'
    javaHomeOption: 'JDKVersion'
    jdkVersionOption: '1.8'
    jdkArchitectureOption: 'x64'
    publishJUnitResults: true
    testResultsFiles: '**/surefire-reports/TEST-*.xml'
    goals: 'integration-test -DskipIntegrationTests=false -Dmaven.test.failure.ignore=false'

Error as below:

[Error] Failures:
[Error] <Filename> errror details
[INFO]
[ERROR] Tests run:2, Failures:2, Errors:0, Skipped:0
[INFO]
[INFO]----------------------------------------------
[INFO] BUILD SUCCESS
[INFO]----------------------------------------------

The failure of the test methods for your project is not the ' Standard Error '. It just a result report of the test methods for your project, and will not be written to the StandardError stream. So, the failure does not affect the final status of the task run.

If you want the job fails when the tests fail, as a workaround, you can try to set up a script to check the test result, and write a ' Standard Error ' (eg Exit 1 ) to the StandardError stream if there is any test fails.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM