Complete the code to define a scripted pipeline stage.
stage('Build') { [1] 'echo Building...' }
The sh step runs shell commands in scripted pipelines, allowing flexible command execution.
Complete the code to start a scripted pipeline with node allocation.
node( [1] ) { stage('Test') { echo 'Running tests' } }
The node block requires a label like 'master' to allocate an executor on that node.
Fix the error in the scripted pipeline to run a shell command conditionally.
if (params.DEPLOY == 'true') { [1] 'echo Deploying application' }
The sh step is needed to run shell commands inside the conditional block in scripted pipelines.
Fill both blanks to create a map with stage names and their status in a scripted pipeline.
def stages = [[1]: 'SUCCESS', [2]: 'FAILURE']
Maps use key-value pairs. Here, stage names like 'Build' and 'Deploy' are keys with their statuses as values.
Fill all three blanks to define a scripted pipeline with a try-catch block for error handling.
try { [1] 'exit 1' } catch (Exception [2]) { echo 'Caught error: ' + [3].toString() }
The sh step runs the shell command. The catch block uses a variable like e to hold the exception.