0
0
Jenkinsdevops~10 mins

Why testing in pipelines matters in Jenkins - Test Your Understanding

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

Complete the code to add a testing stage in a Jenkins pipeline.

Jenkins
pipeline {
  agent any
  stages {
    stage('Test') {
      steps {
        [1] 'run tests'
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Ainput
Barchive
Csh
Dcheckout
Attempts:
3 left
💡 Hint
Common Mistakes
Using input instead of sh to run tests.
2fill in blank
medium

Complete the code to fail the pipeline if tests fail.

Jenkins
pipeline {
  agent any
  stages {
    stage('Test') {
      steps {
        [1] 'exit 1'
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Aarchive
Becho
Cinput
Dsh
Attempts:
3 left
💡 Hint
Common Mistakes
Using echo which only prints text and does not fail the build.
3fill in blank
hard

Fix the error in the pipeline to properly run tests and fail on errors.

Jenkins
pipeline {
  agent any
  stages {
    stage('Test') {
      steps {
        [1] 'pytest || exit 1'
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Ainput
Bsh
Carchive
Dcheckout
Attempts:
3 left
💡 Hint
Common Mistakes
Using input which pauses the pipeline instead of running commands.
4fill in blank
hard

Fill both blanks to add a test stage that runs tests and archives results.

Jenkins
pipeline {
  agent any
  stages {
    stage('Test') {
      steps {
        [1] 'run_tests.sh'
        [2] artifacts: 'test-results/*.xml', fingerprint: true
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Ash
Binput
CarchiveArtifacts
Dcheckout
Attempts:
3 left
💡 Hint
Common Mistakes
Using input instead of sh to run tests.
5fill in blank
hard

Fill all three blanks to create a pipeline that checks out code, runs tests, and archives results.

Jenkins
pipeline {
  agent any
  stages {
    stage('Build and Test') {
      steps {
        [1] scm
        [2] './run_tests.sh'
        [3] artifacts: 'results/*.xml', fingerprint: true
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Acheckout
Bsh
CarchiveArtifacts
Dinput
Attempts:
3 left
💡 Hint
Common Mistakes
Using input which pauses the pipeline instead of running commands.