summaryrefslogtreecommitdiffstats
path: root/policy-management/src/main/server-gen/bin/deploy-artifact
diff options
context:
space:
mode:
authorRashmi Pujar <rashmi.pujar@bell.ca>2020-01-24 15:34:04 -0500
committerRashmi Pujar <rashmi.pujar@bell.ca>2020-01-29 16:08:36 -0500
commitbb03caf94de4ad884e308dbce4992e370638d629 (patch)
treed5083374fff40b9cd96870b9a5d44919071ba3e3 /policy-management/src/main/server-gen/bin/deploy-artifact
parenta54a2373f1b48cdb64d4920ec57ffeab4f228814 (diff)
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 <rashmi.pujar@bell.ca> Change-Id: I9ea0161b45d504be4e65a21c95e48dee4a78de3a
Diffstat (limited to 'policy-management/src/main/server-gen/bin/deploy-artifact')
-rw-r--r--policy-management/src/main/server-gen/bin/deploy-artifact53
1 files changed, 47 insertions, 6 deletions
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.
@@ -205,6 +206,40 @@ function getPomAttributes
}
##############################################################################
+# 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 <jar-file>
#
# This function deploys a JAR file in a repository, as well as
@@ -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