0
0
Jenkinsdevops~10 mins

Running unit tests in pipeline 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 run unit tests using the 'sh' step in Jenkins pipeline.

Jenkins
pipeline {
  agent any
  stages {
    stage('Test') {
      steps {
        [1] 'pytest'
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Arun
Bsh
Cexecute
Dscript
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'run' or 'execute' which are not Jenkins pipeline steps.
2fill in blank
medium

Complete the code to define a Jenkins pipeline stage named 'Unit Tests'.

Jenkins
stage('[1]') {
  steps {
    sh 'pytest'
  }
}
Drag options to blanks, or click blank then click option'
ADeploy
BIntegration
CUnit Tests
DBuild
Attempts:
3 left
💡 Hint
Common Mistakes
Using unrelated stage names like 'Build' or 'Deploy'.
3fill in blank
hard

Fix the error in the Jenkins pipeline step to run tests with Python 3.

Jenkins
steps {
  sh '[1] -m pytest'
}
Drag options to blanks, or click blank then click option'
Apython
Bpytest
Cpy
Dpython3
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'python' which may default to Python 2 or wrong version.
4fill in blank
hard

Fill both blanks to run tests only if the branch is 'main'.

Jenkins
when {
  [1] '[2]'
}
Drag options to blanks, or click blank then click option'
Abranch
Benvironment
Cmain
Ddevelop
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'environment' instead of 'branch' or wrong branch name.
5fill in blank
hard

Fill all three blanks to save test results as JUnit reports in Jenkins.

Jenkins
post {
  always {
    junit '[1]/[2].xml'
    archiveArtifacts artifacts: '[3]/*.xml', allowEmptyArchive: true
  }
}
Drag options to blanks, or click blank then click option'
Areports
Btest-results
Attempts:
3 left
💡 Hint
Common Mistakes
Using different folder names causing Jenkins to miss reports.