forked from geoserver/geoserver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions
129 lines (111 loc) · 3.64 KB
/
functions
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# common functions
# get_file <base_url> <file> <dir>
# downlaods file from $base_url/$file into directory $dir
function get_file() {
local base_url=$1
local file=$2
local dir=$3
if [ ! -e $dir ]; then
mkdir $dir
fi
if [ -e $dir/$file ]; then
rm $dir/$file
fi
pushd $dir > /dev/null
wget --no-check-certificate $base_url/$file
popd > /dev/null
}
# setup_artifacts <tag> <suffix>
# downloads artifacts to build installer:
# 1. geoserver bin artifact
# 2. installer specific artifact specified by <suffix>
# files are unpacked into tmp directory
function setup_artifacts() {
local tag=$1
local suf=$2
local gs_artifact=geoserver-$tag-bin.zip
local installer_artifact=geoserver-$tag-$suf.zip
if [ -z $SKIP_DOWNLOAD ]; then
get_file $DIST_URL/$tag $gs_artifact files
get_file $DIST_URL/$tag $installer_artifact files
fi
# unpack the artifacts
if [ -e tmp ]; then
rm -rf tmp
fi
mkdir -p tmp
unzip -d tmp files/$installer_artifact
unzip -d tmp files/$gs_artifact
}
# upload_installer <tag> <file>
# uploads file <file> to distribution server under tag <tag>
function upload_installer() {
local tag=$1
local file=$2
local ssh_opts="-i $DIST_PK -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
if [ -z $SKIP_UPLOAD ]; then
echo "uploading $file"
# add an extra / to beginning of file path to overcome issue with MinGW text substitution
# where the :/ remote path is converted to ;z: (and connection fails to resolve hostname)
# http://www.mingw.org/wiki/Posix_path_conversion
echo "scp $ssh_opts -P $DIST_PORT $file $DIST_USER@$DIST_HOST:/$DIST_PATH/$tag"
scp $ssh_opts -P $DIST_PORT $file $DIST_USER@$DIST_HOST:/$DIST_PATH/$tag
# set access permissions for www
echo "ssh $ssh_opts -p $DIST_PORT $DIST_USER@$DIST_HOST \"chmod 0644 '$DIST_PATH/$tag/$file'\""
ssh $ssh_opts -p $DIST_PORT $DIST_USER@$DIST_HOST "chmod 0644 '$DIST_PATH/$tag/$file'"
fi
}
# start_installer_job <hudson_url> <user> <key> <tag>
# starts a hudson installer job
function start_installer_job() {
local job_url="$1/job/geoserver-installer/buildWithParameters?TAG=$4&token=buildme"
local creds=$2:$3
echo "executing installer job $job_url with credentials $creds"
curl -k --connect-timeout 10 --user $creds $job_url
}
function is_primary_branch_num() {
local str=$1
if [ "$( echo $str | egrep "[0-9]+\.x" )" == "$str" ] || [ "master" == "$str" ]; then
echo "1"
else
echo "0"
fi
}
# is_version_nuym <str>
# tests a string to see if it is a x.y.z or x.y-z style version number
function is_version_num() {
local str=$1
if [ "$( echo $str | egrep "[0-9]+\.[0-9]+((\.|-).*)?" )" == "$str" ]; then
echo "1"
else
if [ "$( echo $str | egrep "[0-9]+-.*" )" == "$str" ]; then
echo "1"
else
echo "0"
fi
fi
}
# get_pom_version <pom>
# gets the version declared in a pom file
function get_pom_version() {
local pom=$1
echo `grep "<version>" $pom | head -n 1 | sed 's/<.*>\(.*\)<\/.*>/\1/g' | sed 's/ //g'`
}
# get_jira_id <tag>
# gets the jira id for a version named <tag>
function get_jira_id() {
local tag=$1
local jira_id=`curl -s -G $JIRA_REST/project/$JIRA_PROJ/versions | tr "{" "\n" | grep -F "\"$tag\"" | tr "," "\n" | grep "\"id\"" | sed 's/"id": *"\([0-9]\+\).*/\1/g'`
#sed 's/"id": *\([0-9]*\).*/\1/g'`
if [ ! -z $jira_id ]; then
echo $jira_id
fi
}
# init_git <user> <emai>
# sets up git config for user/email
function init_git() {
# setup the author, for some reason I can;t for the life of me get to this
# to work properly from a script using the --author option to git commit
git config user.name $1
git config user.email $2
}