| garciadeblas | 17edada | 2016-09-07 15:36:25 +0200 | [diff] [blame] | 1 | #!/bin/bash |
| garciadeblas | f937a8b | 2016-07-21 14:53:32 +0200 | [diff] [blame] | 2 | # |
| garciadeblas | ee04b45 | 2016-09-19 18:07:40 +0200 | [diff] [blame] | 3 | # Copyright 2016 Telefónica Investigación y Desarrollo, S.A.U. |
| 4 | # |
| garciadeblas | f937a8b | 2016-07-21 14:53:32 +0200 | [diff] [blame] | 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | # |
| garciadeblas | ee04b45 | 2016-09-19 18:07:40 +0200 | [diff] [blame] | 17 | # Authors: |
| 18 | # - Gerardo Garcia - gerardo.garciadeblas@telefonica.com |
| garciadeblas | f937a8b | 2016-07-21 14:53:32 +0200 | [diff] [blame] | 19 | # |
| 20 | |
| 21 | HERE=$(realpath $(dirname $0)) |
| 22 | OSM_JENKINS=$(dirname $HERE) |
| 23 | . $OSM_JENKINS/common/all_funcs |
| 24 | |
| 25 | # SET YOU MDG repository name here |
| 26 | export OSM_MDG=RO |
| 27 | OSM_load_config |
| 28 | |
| 29 | |
| garciadeblas | 5dadd5d | 2016-09-30 11:20:57 +0200 | [diff] [blame] | 30 | # Updates all the branches in the local repo (clones if it does not exist) |
| garciadeblas | f937a8b | 2016-07-21 14:53:32 +0200 | [diff] [blame] | 31 | if [ -d $OSM_MDG ]; then |
| garciadeblas | 5dadd5d | 2016-09-30 11:20:57 +0200 | [diff] [blame] | 32 | INFO "reusing existing workspace" |
| 33 | cd $OSM_MDG |
| 34 | git pull --all |
| 35 | #git checkout master #to make sure that we are in the right branch before pulling the code |
| 36 | #git pull |
| garciadeblas | f937a8b | 2016-07-21 14:53:32 +0200 | [diff] [blame] | 37 | else |
| garciadeblas | 5dadd5d | 2016-09-30 11:20:57 +0200 | [diff] [blame] | 38 | INFO "cloning MDG $OSM_MDG from $OSM_GIT_URL/$OSM_MDG" |
| 39 | git clone $OSM_GIT_URL/$OSM_MDG |
| 40 | cd $OSM_MDG |
| 41 | for remote in `git branch -r`; do git branch --track ${remote#origin/} $remote; done |
| garciadeblas | f937a8b | 2016-07-21 14:53:32 +0200 | [diff] [blame] | 42 | fi |
| garciadeblas | dc5ae19 | 2016-09-08 10:19:24 +0200 | [diff] [blame] | 43 | |
| garciadeblas | a8cbb91 | 2016-08-31 14:47:41 +0200 | [diff] [blame] | 44 | if [ $# -gt 0 ]; then |
| garciadeblas | 5dadd5d | 2016-09-30 11:20:57 +0200 | [diff] [blame] | 45 | if [ "$1" = "checkout" ]; then |
| 46 | INFO "Code to compile: '$2'" |
| 47 | git checkout $2 |
| 48 | else |
| garciadeblas | dc5ae19 | 2016-09-08 10:19:24 +0200 | [diff] [blame] | 49 | INFO "Code to compile: gerrit refspec '$1', commit-id: '$2'" |
| garciadeblas | 5dadd5d | 2016-09-30 11:20:57 +0200 | [diff] [blame] | 50 | git fetch origin $1 || FATAL "git fetch origin '$1' didn't work" |
| 51 | git checkout -f $2 || FATAL "git checkout -f '$2' didn't work" |
| 52 | fi |
| garciadeblas | dc5ae19 | 2016-09-08 10:19:24 +0200 | [diff] [blame] | 53 | else |
| garciadeblas | 5dadd5d | 2016-09-30 11:20:57 +0200 | [diff] [blame] | 54 | INFO "Code to compile: master" |
| 55 | git checkout master |
| garciadeblas | a8cbb91 | 2016-08-31 14:47:41 +0200 | [diff] [blame] | 56 | fi |
| 57 | |
| garciadeblas | f937a8b | 2016-07-21 14:53:32 +0200 | [diff] [blame] | 58 | INFO "starting build" |
| 59 | |
| garciadeblas | ee04b45 | 2016-09-19 18:07:40 +0200 | [diff] [blame] | 60 | INFO " cleaning .pyc" |
| garciadeblas | 3c15859 | 2016-09-20 17:11:49 +0200 | [diff] [blame] | 61 | rm -f *.pyc |
| garciadeblas | ee04b45 | 2016-09-19 18:07:40 +0200 | [diff] [blame] | 62 | INFO " installing openmano packages and dependencies from current repo (--noclone)" |
| garciadeblas | 63dd284 | 2016-10-03 20:21:55 +0200 | [diff] [blame] | 63 | ./scripts/install-openmano.sh --noclone -q |
| garciadeblas | ee04b45 | 2016-09-19 18:07:40 +0200 | [diff] [blame] | 64 | INFO " compiling *.py" |
| tierno | a9c9efe | 2016-09-23 12:27:04 +0200 | [diff] [blame] | 65 | python -m py_compile *.py #&& #uncomment to concatenate commands |
| 66 | #basic test HERE #&& #uncomment to concatenate commands |
| 67 | |
| garciadeblas | a8cbb91 | 2016-08-31 14:47:41 +0200 | [diff] [blame] | 68 | RC=$? |
| garciadeblas | f937a8b | 2016-07-21 14:53:32 +0200 | [diff] [blame] | 69 | INFO "done, RC=$RC" |
| 70 | exit $RC |
| 71 | |
| 72 | |