Create a Pipeline from a Template

Given a pipeline template that defines variables to be resolved per pipeline, you can create pipelines that reference that template and that provide values for all of those variables.

Instantiate a pipeline

  1. Get the pipeline template.

    spin pipeline-template list

    This returns a list of all pipeline templates avaialble in the Spinnaker deployment.

  2. From the list, determine which of the listed templates is the one you want, and get it using the following command:

    spin pipeline-template get --id <pipelineTemplateId>

    This outputs the JSON content of the template. You can save it in a file, or just examine it so that you know what you’re implementing.

  3. Create a file, which will contain the JSON for the pipeline.

    Use the following format:

      “schema”: “v2,
      “application”: “myApp”, # Set this to the app you want to create the pipeline in.
      “name”: “<pipeline name>”, # Pipeline name, remember this for the next part.
      “template”: {
        “source”: “spinnaker://newSpelTemplate” # Reference to the pipeline template we published above. We saved it in Spinnaker, so we prefix the template id with ‘spinnaker://’. ‘http://’ and ‘file://’ prefixes are also supported.
      “variables”: {
        “waitTime”: 4 # Value for the template variable.
      “inherit”: [],
      “triggers”: [],
      “parameters”: [],
      “notifications”: [],
      “description”: “”,
      “stages”: []

    Make sure the content of the file includes, at the beginning, the schema: v2, reference.

  4. Add a reference to the pipeline template:

    In the template element, add a reference to the specific template, using the following format:

    "template": {
    	 "source": "spinnaker://<templateName>"

    Because the template was “saved,” using spin pipeline-template save, it was added to the Spinnaker deployment and is available using spinnaker://.

Provide values for the variables

Note: the variables defined in the pipeline template include default values, so you don’t have to provdide a value for every variabled defined.

In the pipeline JSON file, in the variables section, list each variable for which you’re providing values, and write that value.

Use the following format:

   "variables": {
     "varName": <value>
     "otherVarName": <its_value>

You can code each value by hand in the pipeline JSON that you create. You can also generate the JSON and populate the values programatically. For simplicity This doc describes doing it by hand.

Specify inheritance and overrides

  1. Indicate which elements of the template you want to inherit.

    By default, the pipeline instance inherits the stages from pipeline.stages only. Anything else you want to inherit, from inside pipeline you have to identify explicitly. For example, the template might have a trigger defined in the triggers element, but that trigger is not used in your pipeline unless you include triggers inside the inherit element.

  2. If you want, you can override elements in the template.

Add new stages

Create a new stage by adding the stage spec to the pipeline JSON.

Include an inject element, indicating the stage’s position by identifying which stage this new stage comes after.

In the example below, the new stage wait0 is injected after the wait2 stage.

"stages": [
        "id": "wait2",
        "type": "wait",
        "config": {
            "waitTime": 67
        "id": "wait0",
        "inject": {
            "after": ["wait2"]
        "type": "wait",
        "config": {
            "waitTime": 2

Add a branch to the pipeline

The template you’re using might itself have branches, but if it doesn’t, and you want your pipeline instance to have a branch, inject new stages as described above, but include multiple before or multiple after elements (or both) to describe the graph.

Save the pipeline

spin pipeline save --file <path to pipeline json>