The Load Statement

load < file name >


Imports the pipeline stages, variables and functions in the specified file into your pipeline script.

Since, the load statement can be used at either the top level (importing whole files into global scope) or within a pipeline stage. When inside a pipeline stage, the load statement imports the variables and pipeline stages inside the file into the branch scope of the current branch. This can allow a particular branch of your pipeline to override pipeline stages and variables within that branch to have different values and behavior.

Note: Although you can override the definition of individual pipeline stages dynamically within a branch using load, currently overriding the definition of a segment is not supported.


1. Include a file "dependencies.groovy" explicitly into your pipeline

load "dependencies.groovy"

run {
  hello + world // hello and world are defined in dependencies.groovy

2. Refer to a Variable Defined in an External File



main pipeline script:

load "config.groovy"

// Use realignment if the INCLUDE_REALIGNMENT was defined
  alignment = segment { align + realign }
  alignment = align

run {