Solutions Delivery Platform

Declarative Syntax Support

Pipeline Templates can be written using Declarative Syntax.

An Example

Pipeline Template
pipeline {
  agent any
  stages {
    stage("example") {
      steps {
        echo pipelineConfig.message (1)
        static_code_analysis() (2)
        echo dev.arbitrary_field
      }
    }
  }
}
1 Declarative templates are able to resolve the injected pipelineConfig variable
2 Steps loaded by libraries, such as static_code_analysis in this example, can be resolved in the steps block
Pipeline Configuration
message = "example"
libraries{
  sonarqube (1)
}
application_environments{
  dev{
    arbitrary_field = "whatever" (2)
  }
}
1 the sonarqube library provides the static_code_analysis step in this example
2 the dev application environment is resolvable form the declarative pipeline template

Step Resolution

Occassionally, library developers will create steps in JTE libraries that override actual Jenkins DSL steps (ex: build).

When writing a template using the scripted pipeline syntax, these JTE library steps will take precedence.

However, when writing a pipeline template using the scripted pipeline syntax, the Jenkins DSL step will take precedence.

To invoke the JTE library step, use the script block.

Using the example of a JTE step called build, which overrides the Jenkins DSL step build:

Pipeline Template
pipeline {
  agent any
  stages {
    stage("example") {
      steps {
        build() (1)
        script{
          build() (2)
          steps.build() (3)
        }
      }
    }
  }
}
1 will invoke the Jenkins DSL build step
2 will invoke the JTE library build step
3 will invoke the Jenkins DSL build step using the steps variable, which provides direct access to invoke DSL methods