| Jeremy Mordkoff | 50c2e86 | 2016-06-24 15:26:41 -0400 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # Copyright 2016 RIFT.IO Inc |
| garciadeblas | ee04b45 | 2016-09-19 18:07:40 +0200 | [diff] [blame] | 3 | # Copyright 2016 Telefónica Investigación y Desarrollo S.A.U. |
| Jeremy Mordkoff | 50c2e86 | 2016-06-24 15:26:41 -0400 | [diff] [blame] | 4 | # |
| 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 | # |
| 17 | # start-build is run on a host to start a MDG build |
| 18 | # |
| 19 | # 24 June 2016 -- Jeremy Mordkoff -- Genesis |
| garciadeblas | ee04b45 | 2016-09-19 18:07:40 +0200 | [diff] [blame] | 20 | # -- Gerardo Garcia |
| Jeremy Mordkoff | 50c2e86 | 2016-06-24 15:26:41 -0400 | [diff] [blame] | 21 | |
| 22 | |
| 23 | HERE=$(realpath $(dirname $0)) |
| 24 | OSM_JENKINS=$(dirname $HERE) |
| 25 | . $OSM_JENKINS/common/all_funcs |
| 26 | |
| garciadeblas | 8917310 | 2016-08-31 15:05:33 +0200 | [diff] [blame] | 27 | [ $# -lt 1 ] && FATAL "arg is MDG name" |
| Jeremy Mordkoff | 50c2e86 | 2016-06-24 15:26:41 -0400 | [diff] [blame] | 28 | |
| 29 | export OSM_MDG=$1 |
| garciadeblas | a8cbb91 | 2016-08-31 14:47:41 +0200 | [diff] [blame] | 30 | shift |
| Jeremy Mordkoff | 50c2e86 | 2016-06-24 15:26:41 -0400 | [diff] [blame] | 31 | OSM_load_config |
| 32 | |
| Mike Marchetti | 6930bc0 | 2017-05-31 16:33:02 -0400 | [diff] [blame] | 33 | if [ "$1" = "--build-container" ]; then |
| 34 | shift |
| 35 | [ $# -lt 1 ] && FATAL "missing container name with option --build-container" |
| 36 | export OSM_BUILD_CONTAINER=$1 |
| 37 | shift |
| 38 | fi |
| 39 | |
| Jeremy Mordkoff | 50c2e86 | 2016-06-24 15:26:41 -0400 | [diff] [blame] | 40 | if ! container_exists $OSM_BUILD_CONTAINER; then |
| garciadeblas | ee04b45 | 2016-09-19 18:07:40 +0200 | [diff] [blame] | 41 | CONTAINER_OPTS="" |
| 42 | [[ "$OSM_BUILD_CONTAINER_PRIVILEGED" == yes ]] && CONTAINER_OPTS="$CONTAINER_OPTS -c security.privileged=true" |
| 43 | [[ "$OSM_BUILD_CONTAINER_ALLOW_NESTED" == yes ]] && CONTAINER_OPTS="$CONTAINER_OPTS -c security.nesting=true" |
| Mike Marchetti | 6acd4dc | 2017-05-25 10:48:11 -0400 | [diff] [blame] | 44 | [[ "$OSM_BUILD_CONTAINER_ALLOW_DOCKER" == yes ]] && CONTAINER_OPTS="$CONTAINER_OPTS -p docker -p default" |
| garciadeblas | ee04b45 | 2016-09-19 18:07:40 +0200 | [diff] [blame] | 45 | create_container $OSM_BASE_IMAGE $OSM_BUILD_CONTAINER $CONTAINER_OPTS |
| Jeremy Mordkoff | 50c2e86 | 2016-06-24 15:26:41 -0400 | [diff] [blame] | 46 | wait_container_up $OSM_BUILD_CONTAINER |
| 47 | RE="fedora|fc[0-9]" |
| 48 | if [[ $OSM_BASE_IMAGE =~ $RE ]]; then |
| Jeremy Mordkoff | 158d1d3 | 2016-09-13 10:40:15 -0400 | [diff] [blame] | 49 | container_exec $OSM_BUILD_CONTAINER yum -y install git tar make sudo |
| Jeremy Mordkoff | 50c2e86 | 2016-06-24 15:26:41 -0400 | [diff] [blame] | 50 | else |
| garciadeblas | 7a2b4b7 | 2017-08-31 13:14:45 +0200 | [diff] [blame] | 51 | container_exec $OSM_BUILD_CONTAINER apt-get -y install git realpath make sudo |
| Jeremy Mordkoff | 50c2e86 | 2016-06-24 15:26:41 -0400 | [diff] [blame] | 52 | fi |
| garciadeblas | db26f3c | 2016-09-20 16:46:16 +0200 | [diff] [blame] | 53 | if [ ${OSM_USE_LOCAL_DEVOPS:-false} ]; then |
| 54 | container_push_devops $OSM_BUILD_CONTAINER |
| 55 | else |
| 56 | container_exec $OSM_BUILD_CONTAINER git clone ${OSM_GIT_URL}/devops |
| 57 | fi |
| Jeremy Mordkoff | 50c2e86 | 2016-06-24 15:26:41 -0400 | [diff] [blame] | 58 | else |
| garciadeblas | db26f3c | 2016-09-20 16:46:16 +0200 | [diff] [blame] | 59 | if [ ${OSM_USE_LOCAL_DEVOPS:-false} ]; then |
| 60 | container_push_devops $OSM_BUILD_CONTAINER |
| 61 | else |
| 62 | container_exec $OSM_BUILD_CONTAINER git -C devops pull |
| 63 | fi |
| Jeremy Mordkoff | 50c2e86 | 2016-06-24 15:26:41 -0400 | [diff] [blame] | 64 | fi |
| 65 | |
| garciadeblas | a8cbb91 | 2016-08-31 14:47:41 +0200 | [diff] [blame] | 66 | container_exec $OSM_BUILD_CONTAINER ./devops/jenkins/$OSM_MDG/start_build $* |
| Jeremy Mordkoff | 1921538 | 2016-07-06 18:17:46 -0400 | [diff] [blame] | 67 | RC=$? |
| 68 | INFO "$OSM_MDG build complete. Return code was $RC" |
| 69 | exit $RC |
| garciadeblas | f937a8b | 2016-07-21 14:53:32 +0200 | [diff] [blame] | 70 | |