Skip to content

Commit 360bcee

Browse files
author
J Evelyn Quintana
committed
do not allow promotion if version is wrong
[#150346407](https://www.pivotaltracker.com/story/show/150346407)
1 parent 934d7fa commit 360bcee

File tree

3 files changed

+50
-0
lines changed

3 files changed

+50
-0
lines changed

ci/pipeline.yml

+2
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,8 @@ jobs:
203203
passed:
204204
- bats-centos
205205
- bats-ubuntu
206+
- task: assert-version-aligns
207+
file: bosh-linux-stemcell-builder/ci/tasks/assert-version-aligns.yml
206208
- task: copy-artifacts
207209
file: bosh-linux-stemcell-builder/ci/tasks/publish.yml
208210
params:

ci/tasks/assert-version-aligns.sh

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
export BASE=$(pwd)
6+
7+
semver=`cat ${BASE}/version/number`
8+
9+
pushd "${BASE}/bosh-linux-stemcell-builder"
10+
git_branch=`git branch --list -r --contains HEAD | grep -v 'origin/HEAD' | cut -d'/' -f2`
11+
popd
12+
13+
echo "detected bosh-linux-stemcell-builder will build from branch $git_branch ..."
14+
15+
if [ "$git_branch" = "master" ]; then
16+
version_must_match='^[0-9]+\.0\.0$'
17+
else
18+
version_must_match="^${git_branch//x/[0-9]+.0}$"
19+
version_must_match="${version_must_match//./\.}"
20+
fi
21+
22+
echo "will only continue if version to promote matches $version_must_match ..."
23+
24+
if [[ $semver =~ $version_must_match ]]; then
25+
echo "version $semver is appropriate for branch $git_branch -- promote will continue"
26+
exit 0
27+
fi
28+
29+
echo "version $semver DOES NOT ALIGN with branch $git_branch -- promotion canceled!"
30+
31+
exit 1
32+

ci/tasks/assert-version-aligns.yml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
platform: linux
3+
4+
image_resource:
5+
type: docker-image
6+
source:
7+
repository: bosh/agent
8+
9+
inputs:
10+
- name: bosh-linux-stemcell-builder
11+
- name: version
12+
13+
params: {}
14+
15+
run:
16+
path: bosh-linux-stemcell-builder/ci/tasks/assert-version-aligns.sh

0 commit comments

Comments
 (0)