1. Pipeline DSL

1.1. Jenkinsfile

  • Pipeline model definition

  • Add Jenkinsfile to the repository main folder

  • Bundled with Blue Ocean

  • declarative-linter validate before running job

  • The first line of a Jenkinsfile should be #!/usr/bin/env groovy

  • Automatically create Pipelines for all Branches and Pull Requests

  • Code review/iteration on the Pipeline

  • Audit trail for the Pipeline

  • Single source of truth for the Pipeline, which can be viewed and edited by multiple members of the project.

  • https://jenkins.io/solutions/pipeline/

1.3. Examples

1.3.1. Single Stage

Listing 36. Simple
pipeline {
    agent any

    stages {
        stage('My Stage Name') {
            steps {
                sh '/bin/echo Working...'
            }
        }
    }
}

1.3.2. Multi Stage

Listing 37. Example
pipeline {
    agent any

    stages {
        stage('Build') {
            steps {
                sh '/bin/echo Building...'
            }
        }

        stage('Test') {
            steps {
                sh '/bin/echo Testing...'
            }
        }

        stage('Deploy') {
            steps {
                sh '/bin/echo Deploying...'
            }
        }
    }
}