geoserver

Форк
0
/
functions 
129 строк · 3.6 Кб
1
# common functions
2

3
# get_file <base_url> <file> <dir>
4
# downlaods file from $base_url/$file into directory $dir
5
function get_file() {
6
  local base_url=$1
7
  local file=$2
8
  local dir=$3
9

10
  if [ ! -e $dir ]; then
11
    mkdir $dir
12
  fi
13
  if [ -e $dir/$file ]; then
14
    rm $dir/$file
15
  fi
16
  pushd $dir > /dev/null
17
  wget --no-check-certificate $base_url/$file
18
  popd > /dev/null
19
}
20

21
# setup_artifacts <tag> <suffix>
22
# downloads artifacts to build installer:
23
#   1. geoserver bin artifact
24
#   2. installer specific artifact specified by <suffix>
25
# files are unpacked into tmp directory
26
function setup_artifacts() {
27
  local tag=$1
28
  local suf=$2
29

30
  local gs_artifact=geoserver-$tag-bin.zip
31
  local installer_artifact=geoserver-$tag-$suf.zip
32

33
  if [ -z $SKIP_DOWNLOAD ]; then
34
    get_file $DIST_URL/$tag $gs_artifact files
35
    get_file $DIST_URL/$tag $installer_artifact files
36
  fi
37

38
  # unpack the artifacts
39
  if [ -e tmp ]; then
40
    rm -rf tmp
41
  fi
42
  mkdir -p tmp
43

44
  unzip -d tmp files/$installer_artifact
45
  unzip -d tmp files/$gs_artifact
46
}
47

48
# upload_installer <tag> <file>
49
# uploads file <file> to distribution server under tag <tag>
50
function upload_installer() {
51
  local tag=$1
52
  local file=$2
53
  local ssh_opts="-i $DIST_PK -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
54

55
  if [ -z $SKIP_UPLOAD ]; then
56
    echo "uploading $file"
57
    # add an extra / to beginning of file path to overcome issue with MinGW text substitution
58
    # where the :/ remote path is converted to ;z: (and connection fails to resolve hostname)
59
    # http://www.mingw.org/wiki/Posix_path_conversion
60
    echo "scp $ssh_opts -P $DIST_PORT $file $DIST_USER@$DIST_HOST:/$DIST_PATH/$tag"
61
    scp $ssh_opts -P $DIST_PORT $file $DIST_USER@$DIST_HOST:/$DIST_PATH/$tag
62
    # set access permissions for www
63
    echo "ssh $ssh_opts -p $DIST_PORT $DIST_USER@$DIST_HOST \"chmod 0644 '$DIST_PATH/$tag/$file'\""
64
    ssh $ssh_opts -p $DIST_PORT $DIST_USER@$DIST_HOST "chmod 0644 '$DIST_PATH/$tag/$file'"
65
  fi
66
}
67

68
# start_installer_job <hudson_url> <user> <key> <tag>
69
# starts a hudson installer job
70
function start_installer_job() {
71
  local job_url="$1/job/geoserver-installer/buildWithParameters?TAG=$4&token=buildme"
72
  local creds=$2:$3 
73

74
  echo "executing installer job $job_url with credentials $creds"
75
  curl -k --connect-timeout 10 --user $creds $job_url
76
}
77

78
function is_primary_branch_num() {
79
  local str=$1
80
  if [ "$( echo $str | egrep "[0-9]+\.x" )" == "$str" ] || [ "master" == "$str" ]; then
81
    echo "1"
82
  else
83
    echo "0"
84
  fi
85

86
}
87

88
# is_version_nuym <str>
89
# tests a string to see if it is a x.y.z or x.y-z style version number
90
function is_version_num() {
91
  local str=$1
92
  if [ "$( echo $str | egrep "[0-9]+\.[0-9]+((\.|-).*)?" )" == "$str" ]; then
93
    echo "1"
94
  else
95
     if [ "$( echo $str | egrep "[0-9]+-.*" )" == "$str" ]; then
96
       echo "1"
97
     else
98
       echo "0"
99
     fi
100
  fi
101
}
102

103
# get_pom_version <pom>
104
# gets the version declared in a pom file
105
function get_pom_version() {
106
  local pom=$1
107
  echo `grep "<version>" $pom | head -n 1 | sed 's/<.*>\(.*\)<\/.*>/\1/g' | sed 's/ //g'`
108
}
109

110
# get_jira_id <tag>
111
# gets the jira id for a version named <tag>
112
function get_jira_id() {
113
  local tag=$1
114
  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'`
115

116
  #sed 's/"id": *\([0-9]*\).*/\1/g'`
117
  if [ ! -z $jira_id ]; then
118
    echo $jira_id
119
  fi
120
}
121

122
# init_git <user> <emai>
123
# sets up git config for user/email 
124
function init_git() {
125
  # setup the author, for some reason I can;t for the life of me get to this
126
  # to work properly from a script using the --author option to git commit
127
  git config user.name $1
128
  git config user.email $2
129
}
130

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.