Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The Jenkins DevOps pipeline is defined in a “Jenkinsfile” ‘Jenkinsfile’ (by with the default named filename Jenkinsfile ) and has the following structure (most detail omitted). Paired curly braces ”{ }" an overall structure summarised below. Note that paired curly braces - { } - denote the start and end of a scoped section. Comments are “can be created in a block (/* comment like this */” (inline) or inline (// ” (til end of line)comment like this).

Code Block
pipeline {                    /* outermost scope    # Outermost scope
    agent { ... }      */     agent { ... }     # What are the default agent(s) upon  /* where will this run?which Stages execute?
    environment { ... }             # What (global) variables */are needed?
    parametersstages {  ... }        /* What is it being fed?        # Operational container
   */     environmentstage { ... }       /* what other variables are needed?   */# First Stage (sequence of stagesexecutable {steps)
            agent { ... }  /* operational container       # Which agent is used to execute this Stage?
 */           stageenvironment { ... }     # What /*variables firstare sequenceneeded? of(local stepsto this stage)
         */   steps {
      stage { ... }       /*{ nextstep }            # Executable step
               */ ...
        } ...     }                     # End of first /*Stage
end of stages      stage { ... }             */ } # Second Stage
        ...
    }                               # End of Stage definitions
}                                   //# endEnd of pipelinePipeline

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 your the Jenkins documentation. We present only the MettleCI specific things you need to know. Note that Jenkins offers flexibility in where some of these sections are placed, and in some cases, allows repetition at different scopes. Note also that there are additional things you could put in to just about every section, and that some sections may be repeated at a given scope level.

Sections before “stages”

...

This documentation describes the sample Jenkins pipelines supplied with MettleCI.

Agent Specification

The agent section denotes what class of machines your pipeline can be executed on. For a CI/CD pipeline, you only need to specify this once since all projects are at the same release level. For an upgrade Upgrade pipeline you may want to specify the agents within the stage so that different stages run on different release levels. In the example below the label should match the label you gave your agent on the MettleCI host when you set it up. Pipelines will stall if no running agent with the (matching set of) label(s) is found.

...