...
Code Block |
---|
pipeline { # Outermost scope agent { ... } # What are the default agent(s) upon which Stages execute? parameters { ... } # What values shouldare berequired provided if the pipeline is invoked interactivelyare neededinteractively? 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 parameters
section enumerates the parameters to the pipeline with their default values. 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.
Code Block |
---|
parametersenvironment { 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:
...
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.
Code Block |
---|
environment { DATASTAGE_PROJECT = "${params.projectName}_${params.environmentId}DATASTAGE_PROJECT = "${params.projectName}_${params.environmentId}" ENVIRONMENT_ID = "${params.environmentId}" } |
...
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 stagesStage 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,
...