Skip to content

Commit bb57d1d

Browse files
committed
Pipeline the postgres BOSH release
1 parent 971914b commit bb57d1d

File tree

5 files changed

+401
-0
lines changed

5 files changed

+401
-0
lines changed

ci/pipeline.yml

Lines changed: 206 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,206 @@
1+
---
2+
#
3+
# ci/pipeline.yml
4+
#
5+
# Pipeline structure file for a BOSH Release pipeline
6+
#
7+
# DO NOT MAKE CHANGES TO THIS FILE. Instead, modify
8+
# ci/settings.yml and override what needs overridden.
9+
# This uses spruce, so you have some options there.
10+
#
11+
# author: James Hunt <[email protected]>
12+
# created: 2016-03-30
13+
14+
meta:
15+
name: (( param "Please name your pipeline" ))
16+
target: (( param "Please identify the name of the target Concourse CI" ))
17+
pipeline: (( grab meta.name ))
18+
19+
aws:
20+
bucket: (( concat meta.name "-pipeline" ))
21+
access_key: (( param "Please set your AWS Access Key ID" ))
22+
secret_key: (( param "Please set your AWS Secret Key ID" ))
23+
24+
github:
25+
uri: (( concat "[email protected]:" meta.github.owner "/" meta.github.repo ))
26+
owner: (( param "Please specify the name of the user / organization that owns the Github repository" ))
27+
repo: (( param "Please specify the name of the Github repository" ))
28+
branch: master
29+
private_key: (( param "Please generate an SSH Deployment Key for this repo and specify it here" ))
30+
access_token: (( param "Please generate a Personal Access Token and specify it here" ))
31+
32+
bosh-lite:
33+
target: (( param "Please specify the BOSH target URI for the bosh-lite to run test deployments against" ))
34+
username: admin
35+
password: admin
36+
37+
slack:
38+
webhook: (( param "Please specify your Slack Incoming Webhook Integration URL" ))
39+
notification: '(( concat ":sadpanda: " meta.name " build failed!<br>URL-GOES-HERE" ))'
40+
channel: (( param "Please specify the channel (#name) or user (@user) to send messages to" ))
41+
username: concourse
42+
icon: http://cl.ly/image/3e1h0H3H2s0P/concourse-logo.png
43+
44+
groups:
45+
- name: (( grab meta.name ))
46+
jobs:
47+
- testflight
48+
- rc
49+
- shipit
50+
- major
51+
- minor
52+
53+
jobs:
54+
- name: testflight
55+
public: true
56+
serial: true
57+
plan:
58+
- aggregate:
59+
- { get: git }
60+
- { get: changes, trigger: true }
61+
- task: testflight
62+
config:
63+
platform: linux
64+
image: docker:///starkandwayne/concourse
65+
inputs:
66+
- { name: git }
67+
run:
68+
path: ./git/ci/scripts/testflight
69+
args: []
70+
params:
71+
REPO_ROOT: git
72+
BOSH_LITE_TARGET: (( grab meta.bosh-lite.target ))
73+
BOSH_LITE_USERNAME: (( grab meta.bosh-lite.username ))
74+
BOSH_LITE_PASSWORD: (( grab meta.bosh-lite.password ))
75+
BOSH_LITE_DEPLOYMENT: (( concat "ci-" meta.name ))
76+
77+
- name: rc
78+
public: true
79+
plan:
80+
- aggregate:
81+
- { get: git, trigger: true, passed: [testflight] }
82+
- { get: version, trigger: false, params: {pre: rc} }
83+
- put: version
84+
params: {file: version/number}
85+
86+
- name: minor
87+
public: true
88+
plan:
89+
- { get: version, trigger: false, params: {bump: minor} }
90+
- { put: version, params: {file: version/number} }
91+
92+
- name: major
93+
public: true
94+
plan:
95+
- { get: version, trigger: false, params: {bump: major} }
96+
- { put: version, params: {file: version/number} }
97+
98+
- name: shipit
99+
public: true
100+
serial: true
101+
plan:
102+
- aggregate:
103+
- { get: version, passed: [rc], params: {bump: final} }
104+
- { get: git, passed: [rc] }
105+
- task: release
106+
config:
107+
image: docker:///starkandwayne/concourse
108+
platform: linux
109+
inputs:
110+
- name: version
111+
- name: git
112+
outputs:
113+
- name: gh
114+
- name: pushme
115+
run:
116+
path: ./git/ci/scripts/shipit
117+
args: []
118+
params:
119+
REPO_ROOT: git
120+
VERSION_FROM: version/number
121+
RELEASE_NAME: (( concat meta.name " BOSH Release" ))
122+
RELEASE_ROOT: gh
123+
REPO_OUT: pushme
124+
BRANCH: (( grab meta.github.branch ))
125+
126+
BOSH_LITE_TARGET: (( grab meta.bosh-lite.target ))
127+
BOSH_LITE_USERNAME: (( grab meta.bosh-lite.username ))
128+
BOSH_LITE_PASSWORD: (( grab meta.bosh-lite.password ))
129+
BOSH_LITE_DEPLOYMENT: (( concat "ci-" meta.name ))
130+
131+
AWS_ACCESS_KEY: (( grab meta.aws.access_key ))
132+
AWS_SECRET_KEY: (( grab meta.aws.secret_key ))
133+
134+
- aggregate:
135+
- put: version
136+
params:
137+
bump: patch
138+
- put: git
139+
params:
140+
rebase: true
141+
repository: pushme/git
142+
- put: github
143+
params:
144+
name: gh/name
145+
tag: gh/tag
146+
body: gh/notes.md
147+
globs: [gh/artifacts/*]
148+
- put: s3
149+
params:
150+
from: gh/artifacts/.*-(.*).tgz
151+
152+
resource_types:
153+
- name: slack-notification
154+
type: docker-image
155+
source:
156+
repository: cfcommunity/slack-notification-resource
157+
158+
resources:
159+
- name: git
160+
type: git
161+
source:
162+
uri: (( grab meta.github.uri ))
163+
branch: (( grab meta.github.branch ))
164+
private_key: (( grab meta.github.private_key ))
165+
- name: changes
166+
type: git
167+
source:
168+
uri: (( grab meta.github.uri ))
169+
branch: (( grab meta.github.branch ))
170+
private_key: (( grab meta.github.private_key ))
171+
paths:
172+
- src/**/*
173+
- jobs/**/*
174+
- packages/**/*
175+
- config/blobs.yml
176+
- templates/**/*
177+
178+
- name: version
179+
type: semver
180+
source :
181+
driver: s3
182+
bucket: (( grab meta.aws.bucket ))
183+
key: version
184+
access_key_id: (( grab meta.aws.access_key ))
185+
secret_access_key: (( grab meta.aws.secret_key ))
186+
initial_version: (( grab meta.initial_version || "0.0.1" ))
187+
188+
- name: notify
189+
type: slack-notification
190+
source:
191+
url: (( grab meta.slack.webhook ))
192+
193+
- name: github
194+
type: github-release
195+
source:
196+
user: (( grab meta.github.owner ))
197+
repository: (( grab meta.github.repo ))
198+
access_token: (( grab meta.github.access_token ))
199+
200+
- name: s3
201+
type: s3
202+
source:
203+
bucket: (( grab meta.aws.bucket ))
204+
regexp: (( concat meta.name "-(.*).tgz" ))
205+
access_key_id: (( grab meta.aws.access_key ))
206+
secret_access_key: (( grab meta.aws.secret_key ))

ci/repipe

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#!/bin/bash
2+
#
3+
# ci/repipe
4+
#
5+
# Script for merging together pipeline configuration files
6+
# (via Spruce!) and configuring Concourse.
7+
#
8+
# author: James Hunt <[email protected]>
9+
# Dennis Bell <[email protected]>
10+
# created: 2016-03-04
11+
12+
need_command() {
13+
local cmd=${1:?need_command() - no command name given}
14+
15+
if [[ ! -x "$(command -v $cmd)" ]]; then
16+
echo >&2 "${cmd} is not installed."
17+
if [[ "${cmd}" == "spruce" ]]; then
18+
echo >&2 "Please download it from https://github.com/geofffranks/spruce/releases"
19+
fi
20+
exit 2
21+
fi
22+
}
23+
24+
cd $(dirname $BASH_SOURCE[0])
25+
echo "Working in $(pwd)"
26+
need_command spruce
27+
28+
if [[ -z "$VAULT_ADDR" ]] ; then
29+
echo >&2 "Vault address not specified in VAULT_ADDR environment variable"
30+
exit 1
31+
fi
32+
33+
if [[ ! -f settings.yml ]]; then
34+
echo >&2 "Missing local settings in ci/settings.yml!"
35+
exit 1
36+
fi
37+
38+
set -e
39+
trap "rm -f .deploy.yml" QUIT TERM EXIT INT
40+
spruce merge pipeline.yml settings.yml > .deploy.yml
41+
PIPELINE=$(spruce json .deploy.yml | jq -r '.meta.pipeline // ""')
42+
if [[ -z ${PIPELINE} ]]; then
43+
echo >&2 "Missing pipeline name in ci/settings.yml!"
44+
exit 1
45+
fi
46+
[ -n ${CONCOURSE_TARGET} ] && TARGET=${CONCOURSE_TARGET}
47+
if [[ -z ${TARGET} ]]; then
48+
TARGET=$(spruce json .deploy.yml | jq -r '.meta.target // ""')
49+
fi
50+
if [[ -z ${TARGET} ]]; then
51+
echo >&2 "Missing Concourse Target in ci/settings.yml!"
52+
exit 1
53+
fi
54+
55+
set +x
56+
fly --target ${TARGET} set-pipeline --pipeline ${PIPELINE} --config .deploy.yml
57+
fly --target ${TARGET} unpause-pipeline --pipeline ${PIPELINE}

ci/scripts/shipit

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
#!/bin/bash
2+
#
3+
# ci/scripts/shipit
4+
#
5+
# Script for generating Github release / tag assets
6+
# and managing release notes for a BOSH Release pipeline
7+
#
8+
# author: James Hunt <[email protected]>
9+
# created: 2016-03-30
10+
11+
set -eu
12+
13+
if [[ -z ${VERSION_FROM} ]]; then
14+
echo >&2 "VERSION_FROM environment variable not set, or empty. Did you misconfigure Concourse?"
15+
exit 2
16+
fi
17+
if [[ ! -f ${VERSION_FROM} ]]; then
18+
echo >&2 "Version file (${VERSION_FROM}) not found. Did you misconfigure Concourse?"
19+
exit 2
20+
fi
21+
VERSION=$(cat ${VERSION_FROM})
22+
if [[ -z ${VERSION} ]]; then
23+
echo >&2 "Version file (${VERSION_FROM}) was empty. Did you misconfigure Concourse?"
24+
exit 2
25+
fi
26+
27+
if [[ ! -f ${REPO_ROOT}/ci/release_notes.md ]]; then
28+
echo >&2 "ci/release_notes.md not found. Did you forget to write them?"
29+
exit 1
30+
fi
31+
32+
###############################################################
33+
34+
cat > ~/.bosh_config << EOF
35+
---
36+
aliases:
37+
target:
38+
bosh-lite: ${BOSH_LITE_TARGET}
39+
auth:
40+
${BOSH_LITE_TARGET}:
41+
username: ${BOSH_LITE_USERNAME}
42+
password: ${BOSH_LITE_PASSWORD}
43+
EOF
44+
cat > ${REPO_ROOT}/config/private.yml << EOF
45+
---
46+
blobstore:
47+
s3:
48+
access_key_id: ${AWS_ACCESS_KEY}
49+
secret_access_key: ${AWS_SECRET_KEY}
50+
EOF
51+
bosh target ${BOSH_LITE_TARGET}
52+
(cd ${REPO_ROOT}
53+
bosh -n create release --final --with-tarball --version "${VERSION}")
54+
55+
mkdir -p ${RELEASE_ROOT}/artifacts
56+
echo "v${VERSION}" > ${RELEASE_ROOT}/tag
57+
echo "${RELEASE_NAME} v${VERSION}" > ${RELEASE_ROOT}/name
58+
mv ${REPO_ROOT}/ci/release_notes.md ${RELEASE_ROOT}/notes.md
59+
cp ${REPO_ROOT}/releases/*/*-${VERSION}.tgz ${RELEASE_ROOT}/artifacts
60+
ls -alhR ${RELEASE_ROOT}
61+
62+
cat > ${RELEASE_ROOT}/notification <<EOF
63+
<!here> New ${RELEASE_NAME} v${VERSION} released!
64+
EOF
65+
66+
67+
# GIT!
68+
if [[ -z $(git config --global user.email) ]]; then
69+
git config --global user.email "[email protected]"
70+
fi
71+
if [[ -z $(git config --global user.name) ]]; then
72+
git config --global user.name "CI Bot"
73+
fi
74+
75+
(cd ${REPO_ROOT}
76+
git merge --no-edit ${BRANCH}
77+
git add -A
78+
git status
79+
git commit -m "release v${VERSION}")
80+
81+
# so that future steps in the pipeline can push our changes
82+
cp -a ${REPO_ROOT} ${REPO_OUT}

ci/scripts/testflight

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash
2+
#
3+
# ci/scripts/create-release-and-deploy
4+
#
5+
# Script for generating Github release / tag assets
6+
# and managing release notes for a BOSH Release pipeline
7+
#
8+
# author: James Hunt <[email protected]>
9+
# created: 2016-03-30
10+
11+
cat > ~/.bosh_config << EOF
12+
---
13+
aliases:
14+
target:
15+
bosh-lite: ${BOSH_LITE_TARGET}
16+
auth:
17+
${BOSH_LITE_TARGET}:
18+
username: ${BOSH_LITE_USERNAME}
19+
password: ${BOSH_LITE_PASSWORD}
20+
EOF
21+
22+
set -e
23+
cd ${REPO_ROOT}
24+
git submodule update --init --recursive --force
25+
26+
bosh target ${BOSH_LITE_TARGET}
27+
bosh -n delete deployment ${BOSH_LITE_DEPLOYMENT} --force || echo "continuing on..."
28+
bosh -n create release
29+
bosh -n upload release --rebase || echo "Continuing..."
30+
./templates/make_manifest warden
31+
bosh -n deploy

0 commit comments

Comments
 (0)