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.
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: SUCCESSFor further details, refer to the official Jenkins templating engine documentation and the example code repositories linked at the end of the article.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
DevOps Cloud Academy
Exploring industry DevOps practices and technical expertise.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
