Lisa Revel | 22a0a33 | 2017-02-16 20:14:52 +0000 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # Create a debian package and push to remote repo |
| 3 | # |
Lisa Revel | dae9639 | 2017-02-17 16:29:33 +0000 | [diff] [blame] | 4 | set -x |
Lisa Revel | 656b04c | 2017-02-18 21:55:17 +0000 | [diff] [blame] | 5 | echo '================= STARTING SCRIPT TO CREATE DEBIAN FILE =================' |
| 6 | # Extract the username and password to the nexus repo from the settings file |
Lisa Revel | 22a0a33 | 2017-02-16 20:14:52 +0000 | [diff] [blame] | 7 | USER=$(xpath -q -e "//servers/server[id='ecomp-raw']/username/text()" "$SETTINGS_FILE") |
| 8 | PASS=$(xpath -q -e "//servers/server[id='ecomp-raw']/password/text()" "$SETTINGS_FILE") |
Lisa Revel | 824b7cb | 2017-02-20 01:56:48 +0000 | [diff] [blame^] | 9 | REPO="${NEXUSPROXY}/content/sites/raw" |
Lisa Revel | 22a0a33 | 2017-02-16 20:14:52 +0000 | [diff] [blame] | 10 | |
| 11 | #Create a netrc file for use with curl |
| 12 | NETRC=$(mktemp) |
| 13 | echo "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 |
| 17 | echo "NETRC=$NETRC" > "$WORKSPACE/netrc_env.txt" |
| 18 | |
| 19 | STAGE_DIR=${WORKSPACE}/package |
| 20 | OUTPUT_DIR=${WORKSPACE}/package/output |
| 21 | |
| 22 | DATE_STAMP="$(date +"%Y%m%d%H%M%S")" |
| 23 | PACKAGE_BUILD_NUMBER=${DATE_STAMP} |
| 24 | PACKAGE_NAME_APPLICATION=$( \ |
| 25 | cat ${WORKSPACE}/dcae-apod-buildtools/configs/package-cdap3vm.json | \ |
| 26 | python -c 'import json,sys;print json.load(sys.stdin)["applicationName"]') |
| 27 | PACKAGE_NAME_VERSION=$( \ |
| 28 | cat ${WORKSPACE}/dcae-apod-buildtools/configs/package-cdap3vm.json | \ |
| 29 | python -c 'import json,sys;print json.load(sys.stdin)["version"]') |
| 30 | PACKAGE_GROUP_ID=$( \ |
| 31 | cat ${WORKSPACE}/dcae-apod-buildtools/configs/package-cdap3vm.json | \ |
| 32 | python -c 'import json,sys;print json.load(sys.stdin)["groupId"]') |
| 33 | OUTPUT_FILE="${PACKAGE_NAME_APPLICATION}_${PACKAGE_NAME_VERSION}.deb" |
Lisa Revel | dae9639 | 2017-02-17 16:29:33 +0000 | [diff] [blame] | 34 | OUTPUT_FILE_DATE_STAMPED="${PACKAGE_NAME_APPLICATION}_${PACKAGE_NAME_VERSION}-${DATE_STAMP}.deb" |
Lisa Revel | 22a0a33 | 2017-02-16 20:14:52 +0000 | [diff] [blame] | 35 | |
Lisa Revel | 409c736 | 2017-02-17 00:31:49 +0000 | [diff] [blame] | 36 | echo 'Package variables:' |
Lisa Revel | dae9639 | 2017-02-17 16:29:33 +0000 | [diff] [blame] | 37 | echo " STAGE_DIR = ${STAGE_DIR}" |
Lisa Revel | 409c736 | 2017-02-17 00:31:49 +0000 | [diff] [blame] | 38 | echo " OUTPUT_DIR = ${OUTPUT_DIR}" |
| 39 | echo " PACKAGE_BUILD_NUMBER = ${PACKAGE_BUILD_NUMBER}" |
| 40 | echo " PACKAGE_NAME_APPLICATION = ${PACKAGE_NAME_APPLICATION}" |
| 41 | echo " PACKAGE_NAME_VERSION = ${PACKAGE_NAME_VERSION}" |
| 42 | echo " PACKAGE_GROUP_ID = ${PACKAGE_GROUP_ID}" |
| 43 | echo " OUTPUT_FILE = ${OUTPUT_FILE}" |
| 44 | echo " OUTPUT_FILE_DATE_STAMPED = ${OUTPUT_FILE_DATE_STAMPED}" |
Lisa Revel | 22a0a33 | 2017-02-16 20:14:52 +0000 | [diff] [blame] | 45 | |
Lisa Revel | 409c736 | 2017-02-17 00:31:49 +0000 | [diff] [blame] | 46 | echo 'Creating Staging and Output directories' |
Lisa Revel | 22a0a33 | 2017-02-16 20:14:52 +0000 | [diff] [blame] | 47 | rm -rf ${STAGE_DIR} |
| 48 | rm -rf ${OUTPUT_DIR} |
| 49 | mkdir -p ${STAGE_DIR}/stage/opt/app/dcae-cdap-small-hadoop |
| 50 | mkdir -p ${OUTPUT_DIR} |
| 51 | |
| 52 | echo 'Copying files to stage' |
| 53 | cp -R ${WORKSPACE}/cdap3vm/* ${STAGE_DIR}/stage/opt/app/dcae-cdap-small-hadoop |
| 54 | |
| 55 | echo 'Copying json file to stage' |
| 56 | cp ${WORKSPACE}/dcae-apod-buildtools/configs/package-cdap3vm.json ${STAGE_DIR}/package.json |
| 57 | |
Lisa Revel | 409c736 | 2017-02-17 00:31:49 +0000 | [diff] [blame] | 58 | echo 'Contents of stage directory' |
| 59 | ls -lR ${STAGE_DIR} |
| 60 | |
Lisa Revel | 22a0a33 | 2017-02-16 20:14:52 +0000 | [diff] [blame] | 61 | echo "Creating debian package" |
| 62 | ${WORKSPACE}/dcae-apod-buildtools/scripts/package -b debian -d ${STAGE_DIR} \ |
| 63 | -o ${OUTPUT_DIR} -y package.json -B ${PACKAGE_BUILD_NUMBER} -v |
| 64 | |
Lisa Revel | 22a0a33 | 2017-02-16 20:14:52 +0000 | [diff] [blame] | 65 | # The controller needs the debian packaged named |
| 66 | # dcae-cdap-small-hadoop_17.01.0-LATEST.deb so it can find and deploy it. |
| 67 | # In order to have a copy of each file built a copy of |
| 68 | # dcae-cdap-small-hadoop_17.01.0-LATEST.deb will be made and it will have a |
| 69 | # date stamp and build number on it. |
| 70 | # For example: dcae-cda-small-hadoop_17.01.0-YYYYMMDDHHMMSS-XXX.deb |
| 71 | # Both files will then be uploaded to the repository. |
Lisa Revel | 824b7cb | 2017-02-20 01:56:48 +0000 | [diff] [blame^] | 72 | # Verify script does not upload to Nexus |
Lisa Revel | 22a0a33 | 2017-02-16 20:14:52 +0000 | [diff] [blame] | 73 | |
| 74 | cp ${OUTPUT_DIR}/${OUTPUT_FILE_DATE_STAMPED} ${OUTPUT_DIR}/${OUTPUT_FILE} |
| 75 | |
Lisa Revel | dae9639 | 2017-02-17 16:29:33 +0000 | [diff] [blame] | 76 | echo "Contents of output directory" |
| 77 | ls -lR ${OUTPUT_DIR} |
| 78 | |
Lisa Revel | 656b04c | 2017-02-18 21:55:17 +0000 | [diff] [blame] | 79 | echo '================= ENDING SCRIPT TO CREATE DEBIAN FILE ===================' |