Operations 4 min read

Implementing DevSecOps with Jenkins Template Engine (JTE): Setup, Configuration, and Pipeline Testing

This article explains how to implement DevSecOps across an enterprise using Jenkins Template Engine (JTE), covering preparation of library resources, pipeline template configuration, plugin installation, and a complete pipeline test with sample code and console output.

DevOps Cloud Academy
DevOps Cloud Academy
DevOps Cloud Academy
Implementing DevSecOps with Jenkins Template Engine (JTE): Setup, Configuration, and Pipeline Testing

Implementing DevSecOps across an enterprise is challenging because different teams use various programming languages, test frameworks, and security tools, making it difficult to build and maintain pipelines for each team.

The Jenkins Template Engine (JTE) plugin, originally created by Booz Allen Hamilton, introduces a template‑method design pattern to Jenkins pipelines, allowing tool‑agnostic, reusable pipeline templates stored in a single source repository.

Preparing JTE code

Set up a Library Resources repository where the root contains separate libraries such as gradle and maven. Under each library, a steps directory holds the custom functions.

Configure the pipeline template and associated configuration files, for example:

// Loaded libraries
libraries{
  sonarqube
  gradle
}

// Environment variables
application_environments{
  dev{
    short_name = "t"
  }
  test
}
pipeline{
    agent{
        label "master"
    }

    stages{
        stage("build"){
            steps{
                build(dev.short_name)
                build_test()
            }
        }
    }
}

Installing the JTE plugin

Install the “Templating Engine” plugin in Jenkins, then navigate to System Configuration to configure the plugin as shown in the screenshots.

Pipeline testing

Create a pipeline job and run it. The console output demonstrates JTE loading libraries, applying the template, and executing the defined steps, ending with a SUCCESS status.

Started by user unknown or anonymous
[JTE] Obtained Pipeline Configuration File (show)
[JTE] Pipeline Configuration Modifications (show)
[JTE] Obtained Template (show)
[JTE] Loading Library sonarqube (show)
[JTE] Loading Library gradle (show)
[JTE] Template Primitives are overwriting Jenkins steps with the following names: (show)
[Pipeline] Start of Pipeline
[Pipeline] node
Running on Jenkins in /var/jenkins_home/workspace/demo-jte-pipeline
[Pipeline] {
[Pipeline] stage
[Pipeline] {
  (build)
[JTE][Step - gradle/build.call(String)]
[Pipeline] echo
gradle build
[Pipeline] echo
t
[JTE][Step - gradle/build_test.call()]
[Pipeline] readJSON
[Pipeline] echo
{"name":"jenkins","id":"devopsvip"}
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
Finished: SUCCESS

For further details, refer to the official Jenkins templating engine documentation and the example code repositories linked at the end of the article.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

ci/cdAutomationPipelineDevSecOpsJenkinsTemplateEngine
DevOps Cloud Academy
Written by

DevOps Cloud Academy

Exploring industry DevOps practices and technical expertise.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.