Interview Prep/Jenkins/Scripted pipeline, Groovy & CPS

What does a scripted pipeline look like and when would you still write one?

IntermediateConceptScripted pipeline, Groovy & CPS
Answer
node('linux') {
  stage('Checkout') { checkout scm }
  stage('Build') {
    try {
      sh 'make build'
    } catch (err) {
      currentBuild.result = 'FAILURE'
      throw err
    } finally {
      junit 'reports/*.xml'
    }
  }
}

We still use scripted style inside shared library steps, for dynamically generated stages (one per service discovered at runtime), and for legacy jobs. For application Jenkinsfiles, declarative is the default.

All Jenkins questions Roadmap: Jenkins

More on Scripted pipeline, Groovy & CPS