<commit_before>---
layout: single
title:  "Create a Pipeline from a Template"
sidebar:
  nav: guides
---

{% include toc %}

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.

1. 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.

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

   Use the following format:

   ```json
   {
     “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.

1. Add a reference to the pipeline template:

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

   ```json
   "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<commit_msg>fix(docs): Example config should point to template artifact (#1345)<commit_after>---
layout: single
title:  "Create a Pipeline from a Template"
sidebar:
  nav: guides
---

{% include toc %}

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.

1. 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.

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

   Use the following format:

   ```json
   {
     “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”: {
       “artifactAccount”: “front50ArtifactCredentials”, # Static constant
       “reference”: “spinnaker://newSpelTemplate”, # Reference to the pipeline template we published above. We saved it in Spinnaker, so we prefix the template id with ‘spinnaker://’.
       “type”: “front50/pipelineTemplate”, # Static constant
     },
     “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.

1. Add a reference to the pipeline template:

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

   ```json
   "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
{'fraction_non_alphanumeric': 0.09761045987376014, 'fraction_numerical': 0.004959422903516681, 'mean_word_length': 3.217680608365019, 'pattern_counts': {'":': 4, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5103454', 'n_tokens_mistral': 1244, 'n_tokens_neox': 1177, 'n_words': 564}