From bb03caf94de4ad884e308dbce4992e370638d629 Mon Sep 17 00:00:00 2001 From: Rashmi Pujar Date: Fri, 24 Jan 2020 15:34:04 -0500 Subject: Parameterize mvn repo urls and proxy settings This allows the users to build the docker images for drools-pdp and drools-application using their own CI pipelines if needed. Issue-ID: POLICY-2330 Signed-off-by: Rashmi Pujar Change-Id: I9ea0161b45d504be4e65a21c95e48dee4a78de3a --- .../src/main/server-gen/bin/deploy-artifact | 53 +++++++++++++++++++--- 1 file changed, 47 insertions(+), 6 deletions(-) (limited to 'policy-management/src') diff --git a/policy-management/src/main/server-gen/bin/deploy-artifact b/policy-management/src/main/server-gen/bin/deploy-artifact index 2fc101bd..dab945a8 100644 --- a/policy-management/src/main/server-gen/bin/deploy-artifact +++ b/policy-management/src/main/server-gen/bin/deploy-artifact @@ -5,6 +5,7 @@ # ONAP # ================================================================================ # Copyright (C) 2018-2019 AT&T Intellectual Property. All rights reserved. +# Modifications Copyright (C) 2020 Bell Canada. # ================================================================================ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -204,6 +205,40 @@ function getPomAttributes return ${rval} } +############################################################################## +# Usage: setMavenProxyArgs +# +# This function performs parsing of http proxy environment variable if provided, +# extracting the attributes such as proxy host, port, username and password. +# These proxy attributes are set into the global variable for maven proxy +# settings to be used as build arguments with maven commands. +############################################################################## + +function setMavenProxyArgs +{ + if [[ ${DEBUG} == y ]]; then + echo "-- ${FUNCNAME[0]} $* --" + set -x + fi + + if [[ -z ${http_proxy} ]]; then + return 0 + fi + + local proxy_creds=${http_proxy#*//} + local proxy=${proxy_creds#*@} + local host=${proxy%:*} + local port=${proxy#*:} + MVN_PROXY_SETTINGS="-DproxyHost=${host} -DproxyPort=${port}" + + if [[ "$proxy_creds" == *"@"* ]]; then + local creds=${proxy_creds%%@*} + local username=${creds%:*} + local password=${creds#*:} + MVN_PROXY_SETTINGS+=" -DproxyUsername=${username} -DproxyPassword=${password}" + fi +} + ############################################################################## # Usage: deployJar # @@ -241,7 +276,7 @@ function deployJar echo "${file}: deploying jar artifact to repository ${repoId}: ${repoUrl}" echo "${file}: coordinates ${groupId} ${artifactId} ${version}" - mvn ${CUSTOM_SETTINGS} deploy:deploy-file \ + mvn ${CUSTOM_SETTINGS} ${MVN_PROXY_SETTINGS} deploy:deploy-file \ -Dfile="${file}" \ -Dversion="${version}" \ -Dpackaging=jar \ @@ -290,7 +325,7 @@ function deployPom echo "${file}: deploying pom artifact to repository ${repoId}: ${repoUrl}" echo "${file}: coordinates ${groupId} ${artifactId} ${version}" - mvn ${CUSTOM_SETTINGS} deploy:deploy-file \ + mvn ${CUSTOM_SETTINGS} ${MVN_PROXY_SETTINGS} deploy:deploy-file \ -Dfile="${file}" \ -Dpackaging=pom \ -DgeneratePom=false \ @@ -362,8 +397,8 @@ function installJar return 1 fi - mvn ${CUSTOM_SETTINGS} org.apache.maven.plugins:maven-install-plugin:3.0.0-M1:install-file \ - -Dfile="${file}" + mvn ${CUSTOM_SETTINGS} ${MVN_PROXY_SETTINGS} \ + org.apache.maven.plugins:maven-install-plugin:3.0.0-M1:install-file -Dfile="${file}" return $? } @@ -387,7 +422,8 @@ function installPom return 1 fi - mvn ${CUSTOM_SETTINGS} org.apache.maven.plugins:maven-install-plugin:3.0.0-M1:install-file \ + mvn ${CUSTOM_SETTINGS} ${MVN_PROXY_SETTINGS} \ + org.apache.maven.plugins:maven-install-plugin:3.0.0-M1:install-file \ -Dpackaging=pom \ -Dfile="${file}" \ -DpomFile="${file}" @@ -462,7 +498,8 @@ function installDependencies echo "${file}: deploying dependencies from repository ${DEPENDENCY_REPO_URL}" echo "${file}: coordinates ${groupId} ${artifactId} ${version}" - mvn ${CUSTOM_SETTINGS} org.apache.maven.plugins:maven-dependency-plugin:3.1.1:get \ + mvn ${CUSTOM_SETTINGS} ${MVN_PROXY_SETTINGS} \ + org.apache.maven.plugins:maven-dependency-plugin:3.1.1:get \ -DartifactId="${artifactId}" \ -DgroupId="${groupId}" \ -Dversion="${version}" \ @@ -492,6 +529,7 @@ unset WORKING_POM_PROPERTIES unset DEPENDENCY_REPO_URL unset SETTINGS_FILE unset CUSTOM_SETTINGS +unset MVN_PROXY_SETTINGS # process input @@ -526,6 +564,9 @@ if [[ -n ${SETTINGS_FILE} ]]; then CUSTOM_SETTINGS="--settings=${SETTINGS_FILE}" fi +# Set proxy attributes into MVN_PROXY_SETTINGS variable +setMavenProxyArgs + # retval has the count of failed operations retval=0 -- cgit 1.2.3-korg