blob: d87b49ad05b28d4b4605072daed2671b256766e1 [file] [log] [blame]
Lisa Revel22a0a332017-02-16 20:14:52 +00001#!/bin/bash
2# Create a debian package and push to remote repo
3#
4
5echo '===================== STARTING SCRIPT TO CREATE DEBIAN FILE ======================='
6# Extract the username, password and path to the nexus repo from the maven settings file
7USER=$(xpath -q -e "//servers/server[id='ecomp-raw']/username/text()" "$SETTINGS_FILE")
8PASS=$(xpath -q -e "//servers/server[id='ecomp-raw']/password/text()" "$SETTINGS_FILE")
9OPENECOMP_NEXUS_REPO="${NEXUSPROXY}/content/sites/raw"
10
11#Create a netrc file for use with curl
12NETRC=$(mktemp)
13echo "machine nexus.openecomp.org login $USER password $PASS" > "$NETRC"
14
15
16#Write an envionment var for the netrc location since it's a temp file
17echo "NETRC=$NETRC" > "$WORKSPACE/netrc_env.txt"
18
19STAGE_DIR=${WORKSPACE}/package
20OUTPUT_DIR=${WORKSPACE}/package/output
21
22DATE_STAMP="$(date +"%Y%m%d%H%M%S")"
23PACKAGE_BUILD_NUMBER=${DATE_STAMP}
24PACKAGE_NAME_APPLICATION=$( \
25 cat ${WORKSPACE}/dcae-apod-buildtools/configs/package-cdap3vm.json | \
26 python -c 'import json,sys;print json.load(sys.stdin)["applicationName"]')
27PACKAGE_NAME_VERSION=$( \
28 cat ${WORKSPACE}/dcae-apod-buildtools/configs/package-cdap3vm.json | \
29 python -c 'import json,sys;print json.load(sys.stdin)["version"]')
30PACKAGE_GROUP_ID=$( \
31 cat ${WORKSPACE}/dcae-apod-buildtools/configs/package-cdap3vm.json | \
32 python -c 'import json,sys;print json.load(sys.stdin)["groupId"]')
33OUTPUT_FILE="${PACKAGE_NAME_APPLICATION}_${PACKAGE_NAME_VERSION}.deb"
34OUTPUT_FILE_DATE_STAMPED= \
35 "${PACKAGE_NAME_APPLICATION}_${PACKAGE_NAME_VERSION}-${DATE_STAMP}.deb"
36
Lisa Revel409c7362017-02-17 00:31:49 +000037echo 'Package variables:'
38echo " STAGE_DIR = ${STATE_DIR}"
39echo " OUTPUT_DIR = ${OUTPUT_DIR}"
40echo " PACKAGE_BUILD_NUMBER = ${PACKAGE_BUILD_NUMBER}"
41echo " PACKAGE_NAME_APPLICATION = ${PACKAGE_NAME_APPLICATION}"
42echo " PACKAGE_NAME_VERSION = ${PACKAGE_NAME_VERSION}"
43echo " PACKAGE_GROUP_ID = ${PACKAGE_GROUP_ID}"
44echo " OUTPUT_FILE = ${OUTPUT_FILE}"
45echo " OUTPUT_FILE_DATE_STAMPED = ${OUTPUT_FILE_DATE_STAMPED}"
Lisa Revel22a0a332017-02-16 20:14:52 +000046
Lisa Revel409c7362017-02-17 00:31:49 +000047echo 'Creating Staging and Output directories'
Lisa Revel22a0a332017-02-16 20:14:52 +000048rm -rf ${STAGE_DIR}
49rm -rf ${OUTPUT_DIR}
50mkdir -p ${STAGE_DIR}/stage/opt/app/dcae-cdap-small-hadoop
51mkdir -p ${OUTPUT_DIR}
52
53echo 'Copying files to stage'
54cp -R ${WORKSPACE}/cdap3vm/* ${STAGE_DIR}/stage/opt/app/dcae-cdap-small-hadoop
55
56echo 'Copying json file to stage'
57cp ${WORKSPACE}/dcae-apod-buildtools/configs/package-cdap3vm.json ${STAGE_DIR}/package.json
58
Lisa Revel409c7362017-02-17 00:31:49 +000059echo 'Contents of stage directory'
60ls -lR ${STAGE_DIR}
61
Lisa Revel22a0a332017-02-16 20:14:52 +000062echo "Creating debian package"
63${WORKSPACE}/dcae-apod-buildtools/scripts/package -b debian -d ${STAGE_DIR} \
64 -o ${OUTPUT_DIR} -y package.json -B ${PACKAGE_BUILD_NUMBER} -v
65
66
Lisa Revel409c7362017-02-17 00:31:49 +000067echo "Contents of output directory"
68ls -lR ${OUTPUT_DIR}
69
Lisa Revel22a0a332017-02-16 20:14:52 +000070# The controller needs the debian packaged named
71# dcae-cdap-small-hadoop_17.01.0-LATEST.deb so it can find and deploy it.
72# In order to have a copy of each file built a copy of
73# dcae-cdap-small-hadoop_17.01.0-LATEST.deb will be made and it will have a
74# date stamp and build number on it.
75# For example: dcae-cda-small-hadoop_17.01.0-YYYYMMDDHHMMSS-XXX.deb
76# Both files will then be uploaded to the repository.
77
78cp ${OUTPUT_DIR}/${OUTPUT_FILE_DATE_STAMPED} ${OUTPUT_DIR}/${OUTPUT_FILE}
79
80SEND_TO= \
81"${OPENECOMP_NEXUS_REPO}/org.openecomp.dcae.apod.cdap/deb-snapshots/${PACKAGE_GROUP_ID}/${OUTPUT_FILE}"
Lisa Revel409c7362017-02-17 00:31:49 +000082echo "Sending ${OUTPUT_DIR}/${OUTPUT_FILE} to Nexus Repo: ${SEND_TO}"
Lisa Revel22a0a332017-02-16 20:14:52 +000083curl -vkn --netrc-file "${NETRC}" --upload-file ${OUTPUT_DIR}/${OUTPUT_FILE} ${SEND_TO}
84
85SEND_TO= \
86"${OPENECOMP_NEXUS_REPO}/org.openecomp.dcae.apod.cdap/deb-snapshots/${PACKAGE_GROUP_ID}/${OUTPUT_FILE_DATE_STAMPED}"
Lisa Revel409c7362017-02-17 00:31:49 +000087
88echo "Sending ${OUTPUT_DIR}/${OUTPUT_FILE_DATE_STAMPED} to Nexus Repo: ${SEND_TO}"
Lisa Revel22a0a332017-02-16 20:14:52 +000089curl -vkn --netrc-file "${NETRC}" --upload-file ${OUTPUT_DIR}/${OUTPUT_FILE_DATE_STAMPED} ${SEND_TO}
90
91echo '===================== ENDING SCRIPT TO CREATE DEBIAN FILE ======================='