Complete the code to start a declarative Jenkins pipeline.
pipeline {
agent any
stages {
stage('Build') {
steps {
[1] 'echo Building...'
}
}
}
}In declarative pipelines, sh is used to run shell commands inside steps.
Complete the code to define a scripted Jenkins pipeline node block.
node {
stage('Test') {
[1] 'echo Testing...'
}
}In scripted pipelines, sh runs shell commands inside the node block.
Fix the error in the scripted pipeline to properly wrap shell commands.
node {
stage('Deploy') {
[1] {
sh 'echo Deploying...'
}
}
}In scripted pipelines, script block is used to wrap multiple steps or commands.
Fill both blanks to create a declarative pipeline with a post action.
pipeline {
agent any
stages {
stage('Build') {
steps {
sh 'echo Building...'
}
}
}
post {
[1] {
[2] 'echo Cleaning up...'
}
}
}The post section uses conditions like always to run steps such as sh commands after the pipeline.
Fill all three blanks to create a scripted pipeline with a stage and shell command.
node {
stage('[1]') {
[2] '[3]'
}
}The stage name is 'Deploy', the shell command is run with sh, and the command string is 'echo Deploying...'.