Skip to content

Pipeline Initialization

Pipeline Initialization is the term JTE uses to describe everything that happens from when a Pipeline Run is started to when the Pipeline starts.

Overview

This stages of Pipeline Initialization are described in the table and picture below.

Placeholder

Stage Description
Pipeline Configuration Aggregation Pipeline Configurations fetched from Governance Tiers in the Configuration Hierarchy and merged, creating an Aggregated Pipeline Configuration
Pipeline Primitives Injected JTE parses the aggregated Pipeline Configuration and creates the corresponding Pipeline Primitives
Pipeline Template Determined JTE determines the Pipeline Template to use according to the process outlined in Pipeline Template Selection
Pipeline Template Compiled The groovy Pipeline Template is compiled into the final form that will be executed the same way as any other Jenkinsfile

Pipeline Configuration Aggregation

During the Pipeline Configuration Aggregation phase, JTE fetches the Pipeline Configuration from each Governance Tier (if present) in the Configuration Hierarchy.

Placeholder

These Pipeline Configurations are then sequentially merged, according to the procedure outlined in Merging Pipeline Configurations.

Placeholder

The result of this process is an aggregated Pipeline Configuration for the Pipeline Run. The Map representation of the aggregated Pipeline Configuration is made available via the pipelineConfig Autowired Variable.

Pipeline Primitives Injected

This next phase of Pipeline Initialization takes the aggregated Pipeline Configuration and parses it to create Pipeline Primitives.

This happens by passing the aggregated Pipeline Configuration to a series of Template Primitive Injectors. Each Pipeline Primitive has a corresponding Template Primitive Injector that reads the aggregated Pipeline Configuration and creates the corresponding Pipeline Primitives.

Placeholder

The Pipeline Primitives created during this phase are stored on the Pipeline Primitive Namespace.

Important

You may remember from reading the Pipeline Configuration Syntax that JTE's Pipeline Configuration DSL is just a dynamic builder language, meaning that it will accept any configurations it is given. The only reason application_environments does anything is because there is a Template Primitive Injector that specifically looks for that block.

Pipeline Template Determined

Next, JTE determines the Pipeline Template based on the process outlined in Pipeline Template Selection.

Pipeline Template Compiled

Finally, the determined Pipeline Template is compiled.

JTE performs some Compile-Time Metaprogramming to wrap the Pipeline Template in a Try-Catch-Finally block so that the Lifecycle Hooks can be executed before and after Pipeline Template Execution.

This compiled Pipeline is then executed just like any other Jenkinsfile.

Pipeline Template Compilation

JTE performs compile-time metaprogramming to slightly manipulate the Pipeline Template. What follows is an example to understand the transformation that takes place.

Jenkinsfile
build()
Jenkinsfile
try{
  // code that invokes @Validation annotated methods in steps
  // code that invokes @Init annotated methods in steps 
  build() // <-- original Pipeline Template
} finally {
  // code that invokes @CleanUp annotated methods in steps
  // code that invokes @Notify annotated methods in steps
}
Back to top