Write the Template
In JTE, instead of creating application-specific
Jenkinsfiles we create pipeline templates that represent the business logic of a pipeline in a tool-agnostic way.
To demonstrate this, first create a
From the Jenkins home page, navigate to
New Itemin the lefthand navigation menu.
Enter a name for the job to be created
Pipelinefrom the list of available job types
For this lab, let’s create a pipeline that can build an artifact with maven and then perform static code analysis with SonarQube.
Scroll down on the job’s configuration page to the
Pipeline configuration section.
Make sure that
Jenkins Templating Engine is selected in the
Definition drop down configuration option.
Check the box for
Provide default pipeline template (Jenkinsfile).
Jenkinsfile text box, enter:
A word on vocabulary: The entire script above is called a Pipeline Template. Pipeline Templates invoke steps, in this case build & static_code_analysis, that are implemented by libraries.
You can click
Apply to save your progress. In the next section we’ll be creating the pipeline libraries that implement the