From 4ca06084af59256c8576ba70ba3475d445e8bea0 Mon Sep 17 00:00:00 2001 From: Lusheng Ji Date: Thu, 21 Sep 2017 04:28:03 +0000 Subject: Change pom parent to dcaegen2 Issue-Id: DCAEGEN2-103 Change-Id: I935811ec1c0b8440bc42f3e0cc59cd32054e1224 Signed-off-by: Lusheng Ji --- mvn-phase-lib.sh | 108 ++++++++++++++++++++++++++++++++++++++++++++++++---- mvn-phase-script.sh | 66 ++++++++++---------------------- pom.xml | 13 +++++-- 3 files changed, 130 insertions(+), 57 deletions(-) diff --git a/mvn-phase-lib.sh b/mvn-phase-lib.sh index 6736048..5a25896 100755 --- a/mvn-phase-lib.sh +++ b/mvn-phase-lib.sh @@ -19,6 +19,68 @@ # ECOMP is a trademark and service mark of AT&T Intellectual Property. +#MVN_PROJECT_MODULEID="$1" +#MVN_PHASE="$2" +#PROJECT_ROOT=$(dirname $0) + +FQDN="${MVN_PROJECT_GROUPID}.${MVN_PROJECT_ARTIFACTID}" +if [ "$MVN_PROJECT_MODULEID" == "__" ]; then + MVN_PROJECT_MODULEID="" +fi + +if [[ "$MVN_PROJECT_VERSION" == *SNAPSHOT ]]; then + echo "=> for SNAPSHOT artifact build" + MVN_DEPLOYMENT_TYPE='SNAPSHOT' +else + echo "=> for STAGING/RELEASE artifact build" + MVN_DEPLOYMENT_TYPE='STAGING' +fi +echo "MVN_DEPLOYMENT_TYPE is [$MVN_DEPLOYMENT_TYPE]" + + +TIMESTAMP=$(date +%C%y%m%dT%H%M%S) + +# expected environment variables +if [ -z "${MVN_NEXUSPROXY}" ]; then + echo "MVN_NEXUSPROXY environment variable not set. Cannot proceed" + exit +fi +MVN_NEXUSPROXY_HOST=$(echo "$MVN_NEXUSPROXY" |cut -f3 -d'/' | cut -f1 -d':') +echo "=> Nexus Proxy at $MVN_NEXUSPROXY_HOST, $MVN_NEXUSPROXY" + +if [ -z "$WORKSPACE" ]; then + WORKSPACE=$(pwd) +fi + +if [ -z "$SETTINGS_FILE" ]; then + echo "SETTINGS_FILE environment variable not set. Cannot proceed" + exit +fi + + + +# mvn phase in life cycle +MVN_PHASE="$2" + +echo "MVN_PROJECT_MODULEID is [$MVN_PROJECT_MODULEID]" +echo "MVN_PHASE is [$MVN_PHASE]" +echo "MVN_PROJECT_GROUPID is [$MVN_PROJECT_GROUPID]" +echo "MVN_PROJECT_ARTIFACTID is [$MVN_PROJECT_ARTIFACTID]" +echo "MVN_PROJECT_VERSION is [$MVN_PROJECT_VERSION]" +echo "MVN_NEXUSPROXY is [$MVN_NEXUSPROXY]" +echo "MVN_RAWREPO_BASEURL_UPLOAD is [$MVN_RAWREPO_BASEURL_UPLOAD]" +echo "MVN_RAWREPO_BASEURL_DOWNLOAD is [$MVN_RAWREPO_BASEURL_DOWNLOAD]" +MVN_RAWREPO_HOST=$(echo "$MVN_RAWREPO_BASEURL_UPLOAD" | cut -f3 -d'/' |cut -f1 -d':') +echo "MVN_RAWREPO_HOST is [$MVN_RAWREPO_HOST]" +echo "MVN_RAWREPO_SERVERID is [$MVN_RAWREPO_SERVERID]" +echo "MVN_DOCKERREGISTRY_DAILY is [$MVN_DOCKERREGISTRY_DAILY]" +echo "MVN_DOCKERREGISTRY_RELEASE is [$MVN_DOCKERREGISTRY_RELEASE]" + +echo "MVN_PYPISERVER_SERVERID [$MVN_PYPISERVER_SERVERID]" +echo "MVN_PYPISERVER_BASEURL is [$MVN_PYPISERVER_BASEURL]" + + + clean_templated_files() { TEMPLATE_FILES=$(find . -name "*-template") @@ -52,7 +114,7 @@ expand_templates() export ONAPTEMPLATE_RAWREPOURL_org_onap_dcaegen2_platform_blueprints_releases="$MVN_RAWREPO_BASEURL_DOWNLOAD/org.onap.dcaegen2.platform.blueprints/releases" export ONAPTEMPLATE_RAWREPOURL_org_onap_dcaegen2_platform_blueprints_snapshots="$MVN_RAWREPO_BASEURL_DOWNLOAD/org.onap.dcaegen2.platform.blueprints/snapshots" - export ONAPTEMPLATE_PYPIURL_org_onap_dcaegen2="${MVN_NEXUSPROXY}/content/sites/pypi" + export ONAPTEMPLATE_PYPIURL_org_onap_dcaegen2="$MVN_PYPISERVER_BASEURL" export ONAPTEMPLATE_DOCKERREGURL_org_onap_dcaegen2_releases="$MVN_DOCKERREGISTRY_DAILY" export ONAPTEMPLATE_DOCKERREGURL_org_onap_dcaegen2_snapshots="$MVN_DOCKERREGISTRY_DAILY/snapshots" @@ -79,7 +141,9 @@ expand_templates() KEY=$(echo "$TEMPLATE" | cut -f1 -d'=') VALUE=$(echo "$TEMPLATE" | cut -f2 -d'=') VALUE2=$(echo "$TEMPLATE" | cut -f2 -d'=' |sed 's/\//\\\//g') - FILES=$(grep -rlv "$KEY") + set +e + FILES=$(grep -rl "$KEY") + set -e if [ -z "$FILES" ]; then continue @@ -167,10 +231,12 @@ upload_raw_file() REPO="$MVN_RAWREPO_BASEURL_UPLOAD" - OUTPUT_FILE=$1 + OUTPUT_FILE=$(echo "$1" | sed -e "s/^.\///") EXT=$(echo "$OUTPUT_FILE" | rev |cut -f1 -d '.' |rev) if [ "$EXT" == 'yaml' ]; then OUTPUT_FILE_TYPE='text/x-yaml' + elif [ "$EXT" == 'json' ]; then + OUTPUT_FILE_TYPE='application/json' elif [ "$EXT" == 'sh' ]; then OUTPUT_FILE_TYPE='text/x-shellscript' elif [ "$EXT" == 'gz' ]; then @@ -183,9 +249,9 @@ upload_raw_file() if [ "$MVN_DEPLOYMENT_TYPE" == 'SNAPSHOT' ]; then - SEND_TO="${REPO}/${FQDN}/snapshots" + SEND_TO="${REPO}/${MVN_PROJECT_GROUPID}/snapshots" elif [ "$MVN_DEPLOYMENT_TYPE" == 'STAGING' ]; then - SEND_TO="${REPO}/${FQDN}/releases" + SEND_TO="${REPO}/{$MVN_PROJECT_GROUPID}/releases" else echo "Unreconfnized deployment type, quit" exit @@ -224,20 +290,48 @@ upload_files_of_extension() } +generate_pypirc_then_publish() +{ + set +x + USER=$(xpath -e "//servers/server[id='$MVN_PYPISERVER_SERVERID']/username/text()" "$SETTINGS_FILE") + PASS=$(xpath -e "//servers/server[id='$MVN_PYPISERVER_SERVERID']/password/text()" "$SETTINGS_FILE") + + if [[ "$MVN_PYPISERVER_BASEURL" != */ ]]; then + MVN_PYPISERVER_BASEURL="${MVN_PYPISERVER_BASEURL}/" + fi + + + cat > ~/.pypirc < for SNAPSHOT artifact build" - MVN_DEPLOYMENT_TYPE='SNAPSHOT' -else - echo "=> for STAGING/RELEASE artifact build" - MVN_DEPLOYMENT_TYPE='STAGING' -fi -echo "MVN_DEPLOYMENT_TYPE is [$MVN_DEPLOYMENT_TYPE]" - - -TIMESTAMP=$(date +%C%y%m%dT%H%M%S) +PROJECT_ROOT=$(dirname $0) # expected environment variables if [ -z "${MVN_NEXUSPROXY}" ]; then echo "MVN_NEXUSPROXY environment variable not set. Cannot proceed" - exit -fi -MVN_NEXUSPROXY_HOST=$(echo "$MVN_NEXUSPROXY" |cut -f3 -d'/' | cut -f1 -d':') -echo "=> Nexus Proxy at $MVN_NEXUSPROXY_HOST, $MVN_NEXUSPROXY" - -if [ -z "$WORKSPACE" ]; then - WORKSPACE=$(pwd) + exit 1 fi - if [ -z "$SETTINGS_FILE" ]; then echo "SETTINGS_FILE environment variable not set. Cannot proceed" - exit + exit 2 fi - -# mvn phase in life cycle -MVN_PHASE="$2" +source "${PROJECT_ROOT}"/mvn-phase-lib.sh -echo "MVN_PROJECT_MODULEID is [$MVN_PROJECT_MODULEID]" -echo "MVN_PHASE is [$MVN_PHASE]" -echo "MVN_PROJECT_GROUPID is [$MVN_PROJECT_GROUPID]" -echo "MVN_PROJECT_ARTIFACTID is [$MVN_PROJECT_ARTIFACTID]" -echo "MVN_PROJECT_VERSION is [$MVN_PROJECT_VERSION]" -echo "MVN_NEXUSPROXY is [$MVN_NEXUSPROXY]" -echo "MVN_RAWREPO_BASEURL_UPLOAD is [$MVN_RAWREPO_BASEURL_UPLOAD]" -echo "MVN_RAWREPO_BASEURL_DOWNLOAD is [$MVN_RAWREPO_BASEURL_DOWNLOAD]" -MVN_RAWREPO_HOST=$(echo "$MVN_RAWREPO_BASEURL_UPLOAD" | cut -f3 -d'/' |cut -f1 -d':') -echo "MVN_RAWREPO_HOST is [$MVN_RAWREPO_HOST]" -echo "MVN_RAWREPO_SERVERID is [$MVN_RAWREPO_SERVERID]" -echo "MVN_DOCKERREGISTRY_DAILY is [$MVN_DOCKERREGISTRY_DAILY]" -echo "MVN_DOCKERREGISTRY_RELEASE is [$MVN_DOCKERREGISTRY_RELEASE]" +# This is the base for where "deploy" will upload +# MVN_NEXUSPROXY is set in the pom.xml +REPO=$MVN_NEXUSPROXY/content/sites/raw/$MVN_PROJECT_GROUPID +TIMESTAMP=$(date +%C%y%m%dT%H%M%S) +export BUILD_NUMBER="${TIMESTAMP}" -source ./mvn-phase-lib.sh +shift 2 -# Customize the section below for each project case $MVN_PHASE in clean) echo "==> clean phase script" clean_templated_files clean_tox_files - rm -rf ./venv-* ./*.wgn + rm -rf ./venv-* ./*.wgn ./site ./coverage.xml ./xunit-results.xml ;; generate-sources) echo "==> generate-sources phase script" @@ -102,6 +68,9 @@ compile) ;; test) echo "==> test phase script" + set +e + run_tox_test + set -e ;; package) echo "==> package phase script" @@ -111,6 +80,11 @@ install) ;; deploy) echo "==> deploy phase script" + case $MVN_PROJECT_MODULEID in + *) + #generate_pypirc_then_publish + ;; + esac ;; *) echo "==> unprocessed phase" diff --git a/pom.xml b/pom.xml index 2793979..697c1d9 100644 --- a/pom.xml +++ b/pom.xml @@ -21,12 +21,12 @@ ECOMP is a trademark and service mark of AT&T Intellectual Property. 4.0.0 - org.onap.oparent - oparent + org.onap.dcaegen2 + root 1.0.0-SNAPSHOT - org.onap.dcaegen2 + org.onap.dcaegen2.analytics analytics dcaegen2-analytics 1.0.0-SNAPSHOT @@ -138,6 +138,7 @@ ECOMP is a trademark and service mark of AT&T Intellectual Property. ${session.executionRootDirectory}/mvn-phase-script.sh + ${project.groupId} ${project.artifactId} @@ -146,8 +147,12 @@ ECOMP is a trademark and service mark of AT&T Intellectual Property. ${onap.nexus.rawrepo.baseurl.upload} ${onap.nexus.rawrepo.baseurl.download} ${onap.nexus.rawrepo.serverid} - ${onap.nexus.dockerregistry.daily} + ${onap.nexus.dockerregistry.snapshot} ${onap.nexus.dockerregistry.release} + ${onap.nexus.dockerregistry.snapshot.serverid} + ${onap.nexus.dockerregistry.release.serverid} + ${onap.nexus.pypiserver.baseurl} + ${onap.nexus.pypiserver.serverid} -- cgit 1.2.3-korg