0
0
Jenkinsdevops~10 mins

Failing builds on test failures in Jenkins - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the Jenkins pipeline step to run tests and fail the build on test failures.

Jenkins
stage('Test') {
  steps {
    sh '[1]'
  }
}
Drag options to blanks, or click blank then click option'
Als -l
Brun_tests.sh
Cecho 'Tests passed'
Dpytest --exitfirst
Attempts:
3 left
💡 Hint
Common Mistakes
Using commands that do not run tests.
Using commands that do not fail on test failure.
2fill in blank
medium

Complete the Jenkins pipeline snippet to mark the build as failed if tests fail.

Jenkins
post {
  always {
    junit '[1]'
  }
}
Drag options to blanks, or click blank then click option'
Abuild/output.log
Bsrc/tests
Creports/*.xml
Dtest_results.txt
Attempts:
3 left
💡 Hint
Common Mistakes
Using non-XML files for junit step.
Using incorrect file paths.
3fill in blank
hard

Fix the error in the Jenkins pipeline to fail the build on test failures.

Jenkins
pipeline {
  agent any
  stages {
    stage('Test') {
      steps {
        sh '[1]'
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Apytest
Bpytest || true
Cpytest && echo 'Tests passed'
Decho 'Run tests'
Attempts:
3 left
💡 Hint
Common Mistakes
Adding '|| true' which ignores test failures.
Using echo instead of test commands.
4fill in blank
hard

Fill both blanks to configure Jenkins to archive test reports and fail build on test failures.

Jenkins
post {
  always {
    archiveArtifacts '[1]'
    junit '[2]'
  }
}
Drag options to blanks, or click blank then click option'
Areports/**/*.xml
Breports/*.xml
Dtest-results/*.xml
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong paths for archiving or junit.
Not archiving reports at all.
5fill in blank
hard

Fill all three blanks to create a Jenkins pipeline that runs tests, archives reports, and fails build on test failures.

Jenkins
pipeline {
  agent any
  stages {
    stage('Test') {
      steps {
        sh '[1]'
      }
    }
  }
  post {
    always {
      archiveArtifacts '[2]'
      junit '[3]'
    }
  }
}
Drag options to blanks, or click blank then click option'
Apytest --junitxml=reports/result.xml
Breports/result.xml
Creports/*.xml
Dpytest
Attempts:
3 left
💡 Hint
Common Mistakes
Not generating XML report from tests.
Incorrect paths for archiving or junit.
Using commands that ignore test failures.