Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
497 views
in Technique[技术] by (71.8m points)

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]----------------------------------------------
question from:https://stackoverflow.com/questions/65933692/azure-devops-pipeline-job-shows-success-even-though-the-maven-task-is-failed

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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' (e.g. Exit 1) to the StandardError stream if there is any test fails.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...