Complete the code to define a Jenkins pipeline stage that runs tests.
stage('Test') { steps { [1] 'runTests.sh' } }
In Jenkins pipelines, sh is used to run shell commands.
Complete the code to configure SCM polling with a cron schedule.
pipeline {
agent any
triggers {
pollSCM('[1]')
}
}pollSCM requires a cron expression like H/5 * * * * to schedule SCM polling for changes.
Fix the error in the Jenkinsfile to archive test results.
post {
always {
[1] artifacts: '**/test-results/*.xml', allowEmptyArchive: true
}
}The correct Jenkins step to archive files is archiveArtifacts.
Fill both blanks to define a Jenkins pipeline with environment variables and a build step.
pipeline {
agent any
environment {
APP_ENV = '[1]'
}
stages {
stage('Build') {
steps {
[2] 'build.sh'
}
}
}
}Set APP_ENV to 'production' and use sh to run the build script.
Fill all three blanks to create a Jenkins pipeline that checks out code, runs tests, and archives results.
pipeline {
agent any
stages {
stage('Checkout') {
steps {
[1] scm
}
}
stage('Test') {
steps {
[2] 'runTests.sh'
}
}
}
post {
always {
[3] artifacts: '**/test-results/*.xml'
}
}
}Use checkout to get code, sh to run tests, and archiveArtifacts to save test results.
