0
0
Jenkinsdevops~10 mins

JUnit test report publishing in Jenkins - Interactive Code Practice

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

Complete the code to publish JUnit test reports in a Jenkins pipeline.

Jenkins
post {
  always {
    junit '[1]'
  }
}
Drag options to blanks, or click blank then click option'
Asrc/test/java/*.java
Bpom.xml
C**/target/surefire-reports/*.xml
Dbuild.gradle
Attempts:
3 left
💡 Hint
Common Mistakes
Using source code file paths instead of report XML files.
Forgetting to include the wildcard for XML files.
2fill in blank
medium

Complete the code to archive JUnit test reports as artifacts after the build.

Jenkins
steps {
  archiveArtifacts artifacts: '[1]', allowEmptyArchive: true
}
Drag options to blanks, or click blank then click option'
Abuild/reports/tests/*.html
B**/target/surefire-reports/*.xml
Csrc/test/reports/*.xml
Dlogs/test.log
Attempts:
3 left
💡 Hint
Common Mistakes
Archiving HTML reports instead of XML files.
Using incorrect file paths that do not exist.
3fill in blank
hard

Fix the error in the Jenkins pipeline snippet to correctly publish JUnit test reports.

Jenkins
post {
  always {
    junit '[1]'
  }
}
Drag options to blanks, or click blank then click option'
Atarget/surefire-reports/*.txt
B**/target/surefire-reports/*.html
Ctarget/surefire-reports/*.xml
D**/target/surefire-reports/*.xml
Attempts:
3 left
💡 Hint
Common Mistakes
Using HTML or TXT files instead of XML for JUnit reports.
Not using the recursive glob pattern when reports are in subfolders.
4fill in blank
hard

Fill both blanks to define a Jenkins pipeline stage that runs tests and publishes JUnit reports.

Jenkins
stage('Test') {
  steps {
    sh '[1]'
    junit '[2]'
  }
}
Drag options to blanks, or click blank then click option'
Amvn test
B**/target/surefire-reports/*.xml
Cnpm test
Dbuild/test-results/test/*.xml
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong test command for Maven projects.
Publishing reports from incorrect file paths.
5fill in blank
hard

Fill all three blanks to create a Jenkins pipeline snippet that runs tests, archives reports, and publishes JUnit results.

Jenkins
stage('Test') {
  steps {
    sh '[1]'
    archiveArtifacts artifacts: '[2]', allowEmptyArchive: true
    junit '[3]'
  }
}
Drag options to blanks, or click blank then click option'
Amvn test
B**/target/surefire-reports/*.xml
Dnpm test
Attempts:
3 left
💡 Hint
Common Mistakes
Using different paths for archiving and publishing reports.
Running tests with the wrong command.