initial skeleton for the OSM DevOps build system
[osm/devops.git] / jenkins / host / start_build
diff --git a/jenkins/host/start_build b/jenkins/host/start_build
new file mode 100755 (executable)
index 0000000..09f471b
--- /dev/null
@@ -0,0 +1,45 @@
+#!/bin/bash
+#   Copyright 2016 RIFT.IO Inc
+#
+#   Licensed under the Apache License, Version 2.0 (the "License");
+#   you may not use this file except in compliance with the License.
+#   You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#   Unless required by applicable law or agreed to in writing, software
+#   distributed under the License is distributed on an "AS IS" BASIS,
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#   See the License for the specific language governing permissions and
+#   limitations under the License.
+#
+# start-build is run on a host to start a MDG build
+#
+# 24 June 2016 -- Jeremy Mordkoff -- Genesis
+
+
+HERE=$(realpath $(dirname $0))
+OSM_JENKINS=$(dirname $HERE)
+. $OSM_JENKINS/common/all_funcs
+
+[ $# -eq 1 ] || FATAL "arg is MDG name"
+
+export OSM_MDG=$1
+OSM_load_config
+
+if ! container_exists $OSM_BUILD_CONTAINER; then
+       create_container $OSM_BASE_IMAGE $OSM_BUILD_CONTAINER
+       wait_container_up $OSM_BUILD_CONTAINER
+       RE="fedora|fc[0-9]"
+       if [[ $OSM_BASE_IMAGE =~ $RE ]]; then
+               container_exec $OSM_BUILD_CONTAINER yum -y install git
+       else
+               container_exec $OSM_BUILD_CONTAINER apt install git
+       fi
+       container_exec $OSM_BUILD_CONTAINER git clone ${OSM_GIT_URL}/devops
+else
+       container_exec $OSM_BUILD_CONTAINER git -C devops pull
+fi
+
+
+container_exec $OSM_BUILD_CONTAINER ./devops/jenkins/$OSM_MDG/start_build