Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using commands that do not run tests.
Using commands that do not fail on test failure.
✗ Incorrect
The command 'pytest --exitfirst' runs tests and stops at the first failure, causing the build to fail if tests fail.
2fill in blank
mediumComplete 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using non-XML files for junit step.
Using incorrect file paths.
✗ Incorrect
The 'junit' step reads test result XML files to mark the build as failed if tests fail.
3fill in blank
hardFix 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Adding '|| true' which ignores test failures.
Using echo instead of test commands.
✗ Incorrect
Using 'pytest' alone will cause the build to fail if tests fail. Adding '|| true' prevents failure.
4fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong paths for archiving or junit.
Not archiving reports at all.
✗ Incorrect
Use 'archiveArtifacts' with a glob pattern to save reports and 'junit' with the correct XML path to mark failures.
5fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Not generating XML report from tests.
Incorrect paths for archiving or junit.
Using commands that ignore test failures.
✗ Incorrect
Run pytest with junitxml output, archive that XML file, and use junit to mark build failure on test failures.