Complete the code to define a CI/CD pipeline step that runs tests automatically.
pipeline {
stages {
stage('Test') {
steps {
sh '[1]'
}
}
}
}The npm test command runs the tests automatically during the CI/CD pipeline.
Complete the code to add a test stage that runs only if the build stage succeeds.
pipeline {
stages {
stage('Build') {
steps {
sh 'make build'
}
}
stage('Test') {
when {
[1] 'Build'
}
steps {
sh 'make test'
}
}
}
}The when { stage 'Build' } condition ensures the Test stage runs only if the Build stage succeeds.
Fix the error in the test command to ensure tests run correctly in the CI/CD pipeline.
steps {
sh '[1]'
}The --ci flag runs tests in continuous integration mode, which is suitable for CI/CD pipelines.
Fill both blanks to create a test report file and archive it after tests run.
steps {
sh 'pytest > [1]'
archiveArtifacts '[2]'
}Redirecting test output to test-results.txt and archiving the same file preserves test logs.
Fill all three blanks to define a pipeline that builds, tests, and deploys only if tests pass.
pipeline {
stages {
stage('Build') {
steps {
sh '[1]'
}
}
stage('Test') {
steps {
sh '[2]'
}
}
stage('Deploy') {
when {
[3] 'Test'
}
steps {
sh 'deploy.sh'
}
}
}
}The pipeline builds with make build, tests with make test, and deploys only if the Test stage succeeds using when { stage 'Test' }.