forked from rcbops/jenkins-build
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjenkins-git-repo-version-bump
executable file
·46 lines (33 loc) · 1.07 KB
/
jenkins-git-repo-version-bump
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/bash
#
set -x
set -e
set -u
GIT_ORGANIZATION_URL=${GIT_ORGANIZATION_URL:-"[email protected]:rcbops-cookbooks"}
VERSION_FILE=${VERSION_FILE:-metatata.rb}
GIT_REPO=${GIT_REPO:-kong}
rm -rf ${GIT_REPO} || :
# Checkout the repo
git clone "${GIT_ORGANIZATION_URL}/${GIT_REPO}.git" 2>/dev/null
cd ${GIT_REPO}
# Setup non-global user.name
git config user.name "rcbjenkins"
git config user.email [email protected]
# Version numbers are in major.minor.build
# Figure out the old version
old_ver=$(cat ${VERSION_FILE} | awk '/^version/{gsub("\042","",$NF);print $NF}')
# Increase the build number
new_ver=$(cat ${VERSION_FILE} | awk '/^version/{gsub("\042","",$NF);split($NF,a,".");print a[1]"."a[2]"."a[3]+1}')
echo "Updating ${GIT_REPO} from ${old_ver} to ${new_ver}"
# Replace the version stanza in the file
sed -i "s/$old_ver/$new_ver/" ${VERSION_FILE}
# Verify that git sees a difference
git status
# Add modifications to git
git add ${VERSION_FILE}
git commit -m "End of sprint version bump."
git push
# Clean up after our selves
echo "Cleaning up"
cd ..
rm -rf ${GIT_REPO}