Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Table of Contents
minLevel1
maxLevel7

Structure

The Jenkins DevOps pipeline is defined in a ‘Jenkinsfile’ (with the default filename Jenkinsfile ) and has an overall structure summarised below. Note that paired curly braces - { } - denote the start and end of a scoped section. Comments can be created in a block (/* comment like this */) or inline (// comment like this).

Code Block
pipeline {                          # Outermost scope
    agent { ... }                   # What are the default agent(s) upon which Stages execute?
    parameters { ... }              # What values are required if the pipeline is invoked interactively?
    environment { ... }             # What (global) variables are needed?
    stages {                        # Operational container
        stage { ... }               # First Stage (sequence of executable steps)
            agent { ... }           # Which agent is used to execute this Stage?
            environment { ... }     # What variables are needed? (local to this stage)
            steps {
                { step }            # Executable step
                ...
        }                           # End of first Stage
        stage { ... }               # Second Stage
        ...
    }                               # End of Stage definitions
}                                   # End of Pipeline

Note that Jenkins offers some flexibility in the structure of the pipeline, and in some cases allows repetition at different scopes. For example, a single Step can optionally contain another Stages {...} container which defines more sub-Stages). To understand these sections in more detail refer to the Jenkins documentation.

Input Values

Parameters section

The parameters section enumerates the parameters to the pipeline with their default values. The four parameters used in the template, and their meanings are discussed in /wiki/spaces/MCIDOC/pages/741310474

Info

note that parameters are immutable, and once set at pipeline (or scope section) start, cannot be changed

Code Block
    parameters {
        string(name: 'domainName', defaultValue: 'services_tier.datamigrators.io:59445', description: 'DataStage Service Tier')
        string(name: 'serverName', defaultValue: 'engine_tier.datamigrators.io', description: 'DataStage Engine Tier')
        string(name: 'projectName', defaultValue: 'wwi_jenkins_ds117', description: 'Logical (unsuffixed) Project Name')
        string(name: 'environmentId', defaultValue: 'ci', description: 'Environment Identifer')
    }

When run interactively, the user will be prompted for these at pipeline start time like so:

...

Note that parameters values are immutable, and once a pipeline is invoked with parameter values those values cannot be changed.

Info

Note that the sample Jenkins pipelines supplied with MettleCI do not make use of parameters as all pipeline values are supplied as Node Properties.

Environment Section

The environment section allows you to derive and set further useful variables. The template pipeline composes the suffixed DataStage project and copies one of the parameters to an all uppercased variable for convenience later.

...

Environment variables can be further manipulated in the same or subsequent environment {} section(s), unlike parameters which, once obtained, cannot be changed

Stages Section

The stages Stages section (see terminology) is a container for an arbitrary number of individual stages, Stage containers, which

Contains Steps - the executable actions

which are normally run in sequence . In the template pipeline there are three, “Deploy”, “Test”, and “Promote”(but can be configure to run in parallel).

Stage section notes

Each stage section begins with a label, which is a quoted arbitrary text string displayed on the pipeline diagram in Blue Ocean when viewing the pipeline,

...