Skip to content

Instantly share code, notes, and snippets.

@jmcarp
Created March 8, 2017 00:18
Show Gist options
  • Save jmcarp/018cc4d9a7c44bc9767fc3645e95782d to your computer and use it in GitHub Desktop.
Save jmcarp/018cc4d9a7c44bc9767fc3645e95782d to your computer and use it in GitHub Desktop.
template-pipeline
#!/usr/bin/env ruby
require 'erb'
require 'yaml'
inputs = ARGV
template = ERB.new(File.read('pipeline.yml.erb'))
b = binding
inputs.each do |input|
YAML.load(File.read(input)).map do |key, value|
b.local_variable_set(key, value)
end
end
puts template.result(b)
---
jobs:
<% releases.map do |release| %>
- name: build-<%= release['name'] %>-release
plan:
- aggregate:
- get: release-git-repo
resource: <%= release['name'] %>-release-git-repo
trigger: true
- get: pipeline-tasks
- get: final-builds-dir-tarball
resource: <%= release['name'] %>-final-builds-dir-tarball
- get: releases-dir-tarball
resource: <%= release['name'] %>-releases-dir-tarball
- task: finalize-release
file: pipeline-tasks/finalize-bosh-release.yml
params:
PRIVATE_YML_CONTENT: <%= options['private_yml'] %>
- aggregate:
- put: <%= release['name'] %>-release-tarball
params:
file: finalized-release/<%= release['name'] %>-*.tgz
- put: <%= release['name'] %>-final-builds-dir-tarball
params:
file: finalized-release/final-builds-dir-<%= release['name'] %>.tgz
- put: <%= release['name'] %>-releases-dir-tarball
params:
file: finalized-release/releases-dir-<%= release['name'] %>.tgz
<% end %>
resources:
- name: pipeline-tasks
type: git
source:
uri: {{pipeline-tasks-git-url}}
branch: {{pipeline-tasks-git-branch}}
<% releases.map do |release| %>
- name: <%= release['name'] %>-release-git-repo
type: git
source:
uri: <%= release['url'] %>
branch: <%= release['branch'] %>
- name: <%= release['name'] %>-release-tarball
type: s3
source:
bucket: <%= options['bucket'] %>
regexp: <%= release['name'] %>-(.*).tgz
access_key_id: <%= options['secret_access_key'] %>
secret_access_key: <%= options['secret_access_key'] %>
region_name: <%= options['region'] %>
server_side_encryption: AES256
- name: <%= release['name'] %>-final-builds-dir-tarball
type: s3
source:
versioned_file: final-builds-dir-<%= release['name'] %>.tgz
regexp: <%= release['name'] %>-(.*).tgz
access_key_id: <%= options['secret_access_key'] %>
secret_access_key: <%= options['secret_access_key'] %>
region_name: <%= options['region'] %>
server_side_encryption: AES256
- name: <%= release['name'] %>-releases-dir-tarball
type: s3
source:
versioned_file: releases-dir-<%= release['name'] %>.tgz
regexp: <%= release['name'] %>-(.*).tgz
access_key_id: <%= options['secret_access_key'] %>
secret_access_key: <%= options['secret_access_key'] %>
region_name: <%= options['region'] %>
server_side_encryption: AES256
<% end %>
releases:
- name: secureproxy
url: https://github.com/18F/cg-secureproxy-boshrelease
branch: master
- name: riemann
url: https://github.com/18F/cg-riemann-boshrelease
branch: master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment