Table of Contents | ||||
---|---|---|---|---|
|
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 should be provided if the pipeline is invoked interactivelyare needed?
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.
Parameters section
The parameters 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
...
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. |
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') } |
...