Browse Source

Add examples of templated pipelines

Signed-off-by: Taylor Silva <tsilva@pivotal.io>
pull/4/head
Taylor Silva 5 years ago
parent
commit
593f91ab36
  1. 7
      pipelines/templates/multiple-files/README.md
  2. 78
      pipelines/templates/multiple-files/jobs.lib.yml
  3. 25
      pipelines/templates/multiple-files/resources.lib.yml
  4. 19
      pipelines/templates/multiple-files/template.yml
  5. 4
      pipelines/templates/multiple-files/vars.yml
  6. 1
      pipelines/templates/simple/README.md
  7. 13
      pipelines/templates/simple/template.yml
  8. 6
      pipelines/templates/simple/vars.yml

7
pipelines/templates/multiple-files/README.md

@ -0,0 +1,7 @@
This pipeline has been split over multiple files. This is an example so the only resource used is the [mock resource](https://github.com/concourse/mock-resource).
Render the template using [ytt](https://github.com/vmware-tanzu/carvel-ytt/releases) and running the following command inside this directory:
```
ytt -f ./
```

78
pipelines/templates/multiple-files/jobs.lib.yml

@ -0,0 +1,78 @@
#@ def unit_tests():
name: unit-tests
plan:
- get: repo
trigger: true
- task: run-unit-tests
config:
platform: linux
image_resource:
type: mock
source:
mirror_self: true
inputs:
- name: repo
run:
path: sh
args:
- -c
- |
echo running the unit tests...
cat repo/branch.txt
sleep 4
echo tests passed!
#@ end
#@ def build_rc_image():
name: build-image
plan:
- get: repo
trigger: true
passed: [unit-tests]
- task: build-image
config:
platform: linux
image_resource:
type: mock
source:
mirror_self: true
inputs:
- name: repo
outputs:
- name: image
run:
path: sh
args:
- -c
- |
echo building the image...
date +%Y-%m-%d > image/version
sleep 2
echo image built!
- put: image-rc
params:
file: image/version
#@ end
#@ def deploy(deployment_env):
name: #@ "deploy-" + deployment_env
plan:
- in_parallel:
- get: repo
passed:
#@ if deployment_env == "dev":
- build-image
#@ elif deployment_env == "prod":
- deploy-dev
#@ end
- get: image-rc
passed:
#@ if deployment_env == "dev":
- build-image
#@ elif deployment_env == "prod":
- deploy-dev
#@ end
- put: #@ deployment_env + "-env"
params:
file: image-rc/oci_image
#@ end

25
pipelines/templates/multiple-files/resources.lib.yml

@ -0,0 +1,25 @@
#@ def resources(branch_name, artifact_slug):
- name: repo
icon: git
type: mock
source:
initial_version: #@ "repo-at-" + branch_name
create_files:
branch.txt: #@ branch_name
- name: image-rc
icon: oci
type: mock
source:
initial_version: #@ artifact_slug + "-rc"
create_files:
oci_image: #@ artifact_slug + "-rc"
- name: dev-env
icon: wrench
type: mock
- name: prod-env
icon: cloud-check
type: mock
#@ end

19
pipelines/templates/multiple-files/template.yml

@ -0,0 +1,19 @@
#@ load("@ytt:data", "data")
#@ load("jobs.lib.yml", "unit_tests", "build_rc_image", "deploy")
#@ load("resources.lib.yml", "resources")
jobs:
- #@ unit_tests()
- #@ build_rc_image()
- #@ deploy("dev")
- #@ deploy("prod")
resources: #@ resources(data.values.branch_name, data.values.artifact_slug)
#! TODO: temp fix to ensure usage of the latest mock resource
resource_types:
- name: mock
type: registry-image
source:
repository: concourse/mock-resource

4
pipelines/templates/multiple-files/vars.yml

@ -0,0 +1,4 @@
#@data/values
---
branch_name: "feature-1024"
artifact_slug: "ft1024"

1
pipelines/templates/simple/README.md

@ -0,0 +1 @@
To render the template download [ytt](https://github.com/vmware-tanzu/carvel-ytt/releases) and run `ytt -f pipeline.yml -f vars.yml > rendered.yml`. `rendered.yml` can then be passed to `fly set-pipeline` or a `set_pipeline` step to set the pipeline.

13
pipelines/templates/simple/template.yml

@ -0,0 +1,13 @@
#@ load("@ytt:data", "data")
jobs:
- name: #@ data.values.job_name + "-job"
plan:
- task: #@ data.values.task_name
config:
platform: linux
image_resource:
type: mock
source: mirror_self: true
run:
path: echo
args: #@ data.values.args

6
pipelines/templates/simple/vars.yml

@ -0,0 +1,6 @@
#@data/values
---
job_name: "hello-world"
task_name: "hello-task"
args:
- "hello world of vars!"
Loading…
Cancel
Save