Complete the code to define a Jenkins pipeline stage.
stage('[1]') { steps { echo 'Building the project' } }
The stage name should be 'Build' to indicate the build step in the pipeline.
Complete the code to trigger a Jenkins pipeline on a GitHub push event.
pipeline {
agent any
triggers {
[1]()
}
stages {
stage('Build') {
steps {
echo 'Building...'
}
}
}
}The 'pollSCM' trigger is commonly used to poll the source control for changes, including GitHub push events.
Fix the error in the Jenkinsfile snippet to correctly checkout code from GitHub.
pipeline {
agent any
stages {
stage('Checkout') {
steps {
[1] scm
}
}
}
}The correct Jenkins pipeline step to checkout code is 'checkout scm'.
Fill both blanks to define environment variables and use them in a Jenkins pipeline.
pipeline {
agent any
environment {
APP_NAME = '[1]'
APP_ENV = '[2]'
}
stages {
stage('Print Env') {
steps {
echo "App: $APP_NAME, Environment: $APP_ENV"
}
}
}
}Setting APP_NAME to 'MyApp' and APP_ENV to 'Production' shows how to define and use environment variables.
Fill all three blanks to create a Jenkins pipeline stage that runs a shell command with parameters.
pipeline {
agent any
stages {
stage('[1]') {
steps {
sh '[2] [3]'
}
}
}
}The stage is named 'Test', running 'npm test --verbose' as the shell command.