summaryrefslogtreecommitdiffstats
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
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
-rw-r--r--packages/base/src/files/etc/m2/settings.xml46
-rw-r--r--packages/base/src/files/etc/m2/standalone-settings.xml36
-rw-r--r--packages/docker/pom.xml4
-rw-r--r--packages/docker/src/main/docker/Dockerfile6
-rw-r--r--packages/install/src/files/base.conf21
-rw-r--r--policy-management/src/main/server-gen/bin/deploy-artifact53
6 files changed, 98 insertions, 68 deletions
diff --git a/packages/base/src/files/etc/m2/settings.xml b/packages/base/src/files/etc/m2/settings.xml
index 21212e0b..ed71e029 100644
--- a/packages/base/src/files/etc/m2/settings.xml
+++ b/packages/base/src/files/etc/m2/settings.xml
@@ -4,11 +4,12 @@
Base Package
================================================================================
Copyright (C) 2017-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.
You may obtain a copy of the License at
-
+
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
@@ -19,18 +20,13 @@
============LICENSE_END=========================================================
-->
-
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
-
<offline>false</offline>
-
<profiles>
-
<profile>
<id>policy-local</id>
-
<repositories>
<repository>
<id>file-repository</id>
@@ -45,12 +41,9 @@
</snapshots>
</repository>
</repositories>
-
</profile>
-
<profile>
<id>policy-releases</id>
-
<repositories>
<repository>
<id>${env.RELEASE_REPOSITORY_ID}</id>
@@ -64,12 +57,9 @@
</snapshots>
</repository>
</repositories>
-
</profile>
-
<profile>
<id>policy-snapshots</id>
-
<repositories>
<repository>
<id>${env.SNAPSHOT_REPOSITORY_ID}</id>
@@ -83,17 +73,14 @@
</snapshots>
</repository>
</repositories>
-
</profile>
-
<profile>
- <id>onap-releases</id>
-
+ <id>releases</id>
<repositories>
<repository>
- <id>onap-releases</id>
- <name>onap-releases</name>
- <url>https://nexus.onap.org/content/repositories/releases/</url>
+ <id>releases</id>
+ <name>releases</name>
+ <url>${env.MVN_RELEASE_REPO_URL}</url>
<releases>
<enabled>true</enabled>
</releases>
@@ -102,18 +89,14 @@
</snapshots>
</repository>
</repositories>
-
</profile>
-
<profile>
-
- <id>onap-snapshots</id>
-
+ <id>snapshots</id>
<repositories>
<repository>
- <id>onap-snapshots</id>
- <name>onap-snapshots</name>
- <url>https://nexus.onap.org/content/repositories/snapshots/</url>
+ <id>snapshots</id>
+ <name>snapshots</name>
+ <url>${env.MVN_SNAPSHOT_REPO_URL}</url>
<releases>
<enabled>false</enabled>
</releases>
@@ -122,19 +105,15 @@
</snapshots>
</repository>
</repositories>
-
</profile>
-
</profiles>
-
<activeProfiles>
<activeProfile>policy-local</activeProfile>
<activeProfile>policy-releases</activeProfile>
<activeProfile>policy-snapshots</activeProfile>
- <activeProfile>onap-releases</activeProfile>
- <activeProfile>onap-snapshots</activeProfile>
+ <activeProfile>releases</activeProfile>
+ <activeProfile>snapshots</activeProfile>
</activeProfiles>
-
<servers>
<server>
<id>${env.SNAPSHOT_REPOSITORY_ID}</id>
@@ -147,5 +126,4 @@
<password>${env.REPOSITORY_PASSWORD}</password>
</server>
</servers>
-
</settings>
diff --git a/packages/base/src/files/etc/m2/standalone-settings.xml b/packages/base/src/files/etc/m2/standalone-settings.xml
index e19180e1..8dff1a67 100644
--- a/packages/base/src/files/etc/m2/standalone-settings.xml
+++ b/packages/base/src/files/etc/m2/standalone-settings.xml
@@ -4,6 +4,7 @@
Base Package
================================================================================
Copyright (C) 2017-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.
@@ -19,18 +20,13 @@
============LICENSE_END=========================================================
-->
-
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
-
<offline>false</offline>
-
<profiles>
-
<profile>
<id>policy-local</id>
-
<repositories>
<repository>
<id>file-repository</id>
@@ -45,17 +41,14 @@
</snapshots>
</repository>
</repositories>
-
</profile>
-
<profile>
- <id>onap-releases</id>
-
+ <id>releases</id>
<repositories>
<repository>
- <id>onap-releases</id>
- <name>onap-releases</name>
- <url>https://nexus.onap.org/content/repositories/releases/</url>
+ <id>releases</id>
+ <name>releases</name>
+ <url>${env.MVN_RELEASE_REPO_URL}</url>
<releases>
<enabled>true</enabled>
</releases>
@@ -64,17 +57,14 @@
</snapshots>
</repository>
</repositories>
-
</profile>
-
<profile>
- <id>onap-snapshots</id>
-
+ <id>snapshots</id>
<repositories>
<repository>
- <id>onap-snapshots</id>
- <name>onap-snapshots</name>
- <url>https://nexus.onap.org/content/repositories/snapshots/</url>
+ <id>snapshots</id>
+ <name>snapshots</name>
+ <url>${env.MVN_SNAPSHOT_REPO_URL}</url>
<releases>
<enabled>false</enabled>
</releases>
@@ -83,15 +73,11 @@
</snapshots>
</repository>
</repositories>
-
</profile>
-
</profiles>
-
<activeProfiles>
<activeProfile>policy-local</activeProfile>
- <activeProfile>onap-releases</activeProfile>
- <activeProfile>onap-snapshots</activeProfile>
+ <activeProfile>releases</activeProfile>
+ <activeProfile>snapshots</activeProfile>
</activeProfiles>
-
</settings>
diff --git a/packages/docker/pom.xml b/packages/docker/pom.xml
index 9a5979a8..d9e2133b 100644
--- a/packages/docker/pom.xml
+++ b/packages/docker/pom.xml
@@ -3,7 +3,7 @@
ONAP Policy Engine - Docker files
================================================================================
Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
- Modifications Copyright (C) 2019 Bell Canada.
+ Modifications Copyright (C) 2019-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.
@@ -45,6 +45,8 @@
<docker.push.registry>nexus3.onap.org:10003</docker.push.registry>
<maven.build.timestamp.format>yyyyMMdd'T'HHmm</maven.build.timestamp.format>
<docker.buildArg.BUILD_VERSION_DROOLS>${project.version}</docker.buildArg.BUILD_VERSION_DROOLS>
+ <docker.buildArg.MVN_SNAPSHOT_REPO_URL>${nexusproxy}/${snapshots.path}</docker.buildArg.MVN_SNAPSHOT_REPO_URL>
+ <docker.buildArg.MVN_RELEASE_REPO_URL>${nexusproxy}/${releases.path}</docker.buildArg.MVN_RELEASE_REPO_URL>
</properties>
<build>
diff --git a/packages/docker/src/main/docker/Dockerfile b/packages/docker/src/main/docker/Dockerfile
index 935ea645..4c9cc9fc 100644
--- a/packages/docker/src/main/docker/Dockerfile
+++ b/packages/docker/src/main/docker/Dockerfile
@@ -5,6 +5,9 @@ LABEL maintainer="Policy Team"
ARG BUILD_VERSION_DROOLS=${BUILD_VERSION_DROOLS}
ARG POLICY_LOGS=/var/log/onap/policy/pdpd
ARG POLICY_INSTALL=/tmp/policy-install
+ARG MVN_SNAPSHOT_REPO_URL
+ARG MVN_RELEASE_REPO_URL
+ARG http_proxy
ENV BUILD_VERSION_DROOLS $BUILD_VERSION_DROOLS
ENV POLICY_INSTALL $POLICY_INSTALL
@@ -13,6 +16,9 @@ ENV POLICY_LOGS $POLICY_LOGS
ENV POLICY_CONFIG $POLICY_HOME/config
ENV POLICY_LOGBACK $POLICY_CONFIG/logback.xml
ENV POLICY_DOCKER true
+ENV MVN_SNAPSHOT_REPO_URL $MVN_SNAPSHOT_REPO_URL
+ENV MVN_RELEASE_REPO_URL $MVN_RELEASE_REPO_URL
+ENV http_proxy $http_proxy
RUN apt-get install -y \
mariadb-client \
diff --git a/packages/install/src/files/base.conf b/packages/install/src/files/base.conf
index 6d80fb56..865a9d18 100644
--- a/packages/install/src/files/base.conf
+++ b/packages/install/src/files/base.conf
@@ -3,6 +3,7 @@
# ONAP POLICY
# ================================================================================
# Copyright (C) 2017-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.
@@ -22,7 +23,7 @@
JVM_OPTIONS=-server -Xms512m -Xmx1024m
-# SYSTEM software configuration
+# SYSTEM software configuration
POLICY_HOME=/opt/app/policy
POLICY_LOGS=/opt/app/policy/logs
@@ -30,6 +31,14 @@ JAVA_HOME=/usr/lib/jvm/java-11-openjdk
KEYSTORE_PASSWD=Pol1cy_0nap
TRUSTSTORE_PASSWD=Pol1cy_0nap
+# System proxy settings
+# Empty by default, http proxy can be overridden during build time.
+# System property settings will always override the project
+# property supplied during build time.
+
+#http_proxy=
+#https_proxy=
+
# Telemetry credentials
TELEMETRY_PORT=9696
@@ -37,7 +46,7 @@ TELEMETRY_HOST=0.0.0.0
TELEMETRY_USER=
TELEMETRY_PASSWORD=
-# nexus repository
+# nexus repository for policy artifacts
SNAPSHOT_REPOSITORY_ID=
SNAPSHOT_REPOSITORY_URL=
@@ -47,6 +56,14 @@ REPOSITORY_USERNAME=
REPOSITORY_PASSWORD=
REPOSITORY_OFFLINE=
+# nexus repository for all other artifacts.
+# By default the repo URLs point to ONAP nexus
+# repositories. These default build settings
+# can be overridden during build time.
+
+#MVN_SNAPSHOT_REPO_URL=https://nexus.onap.org/content/repositories/snapshots/
+#MVN_RELEASE_REPO_URL=https://nexus.onap.org/content/repositories/releases/
+
# Relational (SQL) DB access
SQL_HOST=
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