summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThugutla sailakshmi <tsaila10@in.ibm.com>2019-09-10 16:52:32 +0530
committerThugutla Sai Lakshmi <tsaila10@in.ibm.com>2019-09-18 10:29:00 +0000
commit5b6ecf143a3259131876251fecb2ae2a4ceec01a (patch)
tree5c97981b7a643895781c2d6561b2f01b16f99c68
parent7a31a158ed0452a7f9a35f0a89af30acfd134349 (diff)
docker script file for VALET-API module
docker script file for VALET-API module Issue-ID: OPTFRA-578 Change-Id: I824ab0cdc495105651a4145d95e131219e9a595f Signed-off-by: Thugutla sailakshmi <tsaila10@in.ibm.com>
-rw-r--r--engine/version.properties (renamed from version.properties)9
-rw-r--r--valetapi/build-dockers.sh94
-rw-r--r--valetapi/version.properties28
3 files changed, 126 insertions, 5 deletions
diff --git a/version.properties b/engine/version.properties
index be52259..b847a8d 100644
--- a/version.properties
+++ b/engine/version.properties
@@ -1,7 +1,6 @@
#
# -------------------------------------------------------------------------
-# Copyright (c) 2019 AT&T Intellectual Property
-# Modifications Copyright (C) 2019 IBM
+# Copyright (c) 2015-2017 AT&T Intellectual Property
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -18,9 +17,9 @@
# -------------------------------------------------------------------------
#
-major=1.0.0
-minor=1.0.0
-patch=1.0.0
+major=1
+minor=3
+patch=1
base_version=${major}.${minor}.${patch}
diff --git a/valetapi/build-dockers.sh b/valetapi/build-dockers.sh
new file mode 100644
index 0000000..516f860
--- /dev/null
+++ b/valetapi/build-dockers.sh
@@ -0,0 +1,94 @@
+#!/bin/bash
+
+# The script starts in the root folder of the repo, which has the following outline
+# We fetch the version information from version.properties, build docker files and
+# do a docker push. Since the job will be run under Jenkins, it will have the Nexus
+# credentials
+
+set -e
+
+BUILD_ARGS="--no-cache"
+ORG="onap"
+PROJECT="fgps-api"
+DOCKER_REPOSITORY="nexus.onap.org:5100"
+IMAGE_NAME="${DOCKER_REPOSITORY}/${ORG}/${PROJECT}"
+
+# Version properties
+source version.properties
+VERSION=$release_version
+SNAPSHOT=$snapshot_version
+STAGING=${release_version}-STAGING
+TIMESTAMP=$(date +"%Y%m%dT%H%M%S")Z
+REPO=""
+
+if [ $HTTP_PROXY ]; then
+ BUILD_ARGS+=" --build-arg HTTP_PROXY=${HTTP_PROXY}"
+fi
+if [ $HTTPS_PROXY ]; then
+ BUILD_ARGS+=" --build-arg HTTPS_PROXY=${HTTPS_PROXY}"
+fi
+
+function log_ts() { # Log message with timestamp
+ echo [DEBUG LOG at $(date -u +%Y%m%d:%H%M%S)] "$@"
+}
+
+function get_artifact_version() {
+ log_ts Get Maven Artifact version from pom.xml
+ MVN_ARTIFACT_VERSION=`echo -e "setns x=http://maven.apache.org/POM/4.0.0 \n xpath /x:project/x:version/text() "| xmllint --shell conductor/pom.xml | grep content | sed 's/.*content=//'`
+ log_ts Maven artifact version for fgps-api is $MVN_ARTIFACT_VERSION
+ if [[ "$MVN_ARTIFACT_VERSION" =~ SNAPSHOT ]]; then
+ log_ts "REPO is snapshots";
+ REPO=snapshots
+ else
+ log_ts "REPO is releases";
+ REPO=releases
+ fi
+ BUILD_ARGS+=" --build-arg REPO=${REPO}"
+ BUILD_ARGS+=" --build-arg MVN_ARTIFACT_VERSION=${MVN_ARTIFACT_VERSION}"
+}
+
+function build_image() {
+ log_ts Building Image in folder: $PWD with build arguments ${BUILD_ARGS}
+ mvn clean install
+ cp target/ValetApi.jar src/main/docker
+ docker build ${BUILD_ARGS} -t ${IMAGE_NAME}:latest src/main/docker
+ log_ts ... Built
+}
+
+function push_image() {
+ if [[ "$REPO" == snapshots ]]; then
+ push_snapshot_image
+ else
+ push_staging_image
+ fi
+}
+
+function push_snapshot_image(){
+ log_ts Tagging images: ${IMAGE_NAME}:\{${SNAPSHOT}-${TIMESTAMP},${SNAPSHOT}-latest\}
+ docker tag ${IMAGE_NAME}:latest ${IMAGE_NAME}:${SNAPSHOT}-${TIMESTAMP}
+ docker tag ${IMAGE_NAME}:latest ${IMAGE_NAME}:${SNAPSHOT}-latest
+ log_ts ... Tagged images
+
+ log_ts Pushing images: ${IMAGE_NAME}:\{${SNAPSHOT}-${TIMESTAMP},${SNAPSHOT}-latest\}
+ docker push ${IMAGE_NAME}:${SNAPSHOT}-${TIMESTAMP}
+ docker push ${IMAGE_NAME}:${SNAPSHOT}-latest
+ log_ts ... Pushed images
+}
+
+function push_staging_image(){
+ log_ts Tagging images: ${IMAGE_NAME}:\{${STAGING}-${TIMESTAMP},${STAGING}-latest\}
+ docker tag ${IMAGE_NAME}:latest ${IMAGE_NAME}:${STAGING}-${TIMESTAMP}
+ docker tag ${IMAGE_NAME}:latest ${IMAGE_NAME}:${STAGING}-latest
+ log_ts ... Tagged images
+
+ log_ts Pushing images: ${IMAGE_NAME}:\{${STAGING}-${TIMESTAMP},${STAGING}-latest\}
+ docker push ${IMAGE_NAME}:${STAGING}-${TIMESTAMP}
+ docker push ${IMAGE_NAME}:${STAGING}-latest
+ log_ts ... Pushed images
+}
+
+(
+ get_artifact_version
+ build_image
+ push_image
+)
diff --git a/valetapi/version.properties b/valetapi/version.properties
new file mode 100644
index 0000000..b847a8d
--- /dev/null
+++ b/valetapi/version.properties
@@ -0,0 +1,28 @@
+#
+# -------------------------------------------------------------------------
+# Copyright (c) 2015-2017 AT&T Intellectual Property
+#
+# 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.
+#
+# -------------------------------------------------------------------------
+#
+
+major=1
+minor=3
+patch=1
+
+base_version=${major}.${minor}.${patch}
+
+# Release must be completed with git revision # in Jenkins
+release_version=${base_version}
+snapshot_version=${base_version}-SNAPSHOT