aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@est.tech>2022-06-28 15:55:29 +0100
committerliamfallon <liam.fallon@est.tech>2022-06-29 09:02:48 +0100
commitf66c6832851681a275cf32f77ee5c5575d8d2afd (patch)
treea46bba6f0b16a0432fda34260935f1d4659fc546
parent7b7ee11f58a1cf31bbfa4a41db213ee567f8c725 (diff)
Update get version script for snapshots
The current script assumes that snapshot versions are always available. However the Linux Foundation has now implemented a policy of deleting snapshots on no-master branches that are older than a certain age. THis breaks our CSITs. THis updated script copes with this by checking if a snapshot is avaialable and, if the snapshot is not available, the script falls back to the released version. This script will be needed on other branches besides master as well. Issue-ID: POLICY-4233 Change-Id: I7a9fe7ffc3abfc8044a2e0439e3fcd47c086d5f8 Signed-off-by: liamfallon <liam.fallon@est.tech>
-rw-r--r--csit/compose-grafana.yml2
-rw-r--r--csit/docker-compose-all.yml2
-rw-r--r--csit/docker-compose-gui-smoke.yml2
-rwxr-xr-xcsit/get-versions.sh113
4 files changed, 88 insertions, 31 deletions
diff --git a/csit/compose-grafana.yml b/csit/compose-grafana.yml
index fad1bdfb..f9908533 100644
--- a/csit/compose-grafana.yml
+++ b/csit/compose-grafana.yml
@@ -130,7 +130,7 @@ services:
'pap', '6969'
]
drools:
- image: nexus3.onap.org:10001/onap/policy-drools:${POLICY_DROOLS_VERSION}
+ image: nexus3.onap.org:10001/onap/policy-drools:${POLICY_DROOLS_PDP_VERSION}
container_name: drools
depends_on:
- mariadb
diff --git a/csit/docker-compose-all.yml b/csit/docker-compose-all.yml
index d0edf0ca..ef4bebdf 100644
--- a/csit/docker-compose-all.yml
+++ b/csit/docker-compose-all.yml
@@ -139,7 +139,7 @@ services:
'pap', '6969'
]
drools:
- image: nexus3.onap.org:10001/onap/policy-drools:${POLICY_DROOLS_VERSION}
+ image: nexus3.onap.org:10001/onap/policy-drools:${POLICY_DROOLS_PDP_VERSION}
container_name: drools
depends_on:
- mariadb
diff --git a/csit/docker-compose-gui-smoke.yml b/csit/docker-compose-gui-smoke.yml
index fea29e3d..3ecabc17 100644
--- a/csit/docker-compose-gui-smoke.yml
+++ b/csit/docker-compose-gui-smoke.yml
@@ -137,7 +137,7 @@ services:
'pap', '6969'
]
drools:
- image: nexus3.onap.org:10001/onap/policy-drools:${POLICY_DROOLS_VERSION}
+ image: nexus3.onap.org:10001/onap/policy-drools:${POLICY_DROOLS_PDP_VERSION}
container_name: drools
depends_on:
- mariadb
diff --git a/csit/get-versions.sh b/csit/get-versions.sh
index 87c43b50..30a581b6 100755
--- a/csit/get-versions.sh
+++ b/csit/get-versions.sh
@@ -34,45 +34,102 @@ echo POLICY_MARIADB_VER=${POLICY_MARIADB_VER}
export POLICY_POSTGRES_VER=11.1
echo POLICY_POSTGRES_VER=${POLICY_POSTGRES_VER}
-function getVersion
+function getDockerVersion
{
REPO=$1
- curl -qL --silent \
- https://github.com/onap/policy-"$REPO"/raw/"${GERRIT_BRANCH}"/pom.xml |
- xmllint --xpath \
- '/*[local-name()="project"]/*[local-name()="version"]/text()' - |
- awk -F \. '{print $1"."$2"-SNAPSHOT-latest"}'
+ DEFAULT_DOCKER_IMAGE_NAME=$2
+ DEFAULT_DOCKER_IMAGE_VERSION=$3
+
+ REPO_RELEASE_DATA=$(
+ curl -qL --silent \
+ "https://github.com/onap/policy-parent/raw/$GERRIT_BRANCH/integration/src/main/resources/release/pf_release_data.csv" |
+ grep "^policy/$REPO"
+ )
+
+ # shellcheck disable=SC2034
+ read -r repo \
+ latest_released_tag \
+ latest_snapshot_tag \
+ changed_files \
+ docker_images \
+ <<< "$(echo "$REPO_RELEASE_DATA" | tr ',' ' ' )"
+
+ if [[ -z "$docker_images" ]]
+ then
+ if [[ -z "$DEFAULT_DOCKER_IMAGE_NAME" ]]
+ then
+ echo "repo $REPO does not produce a docker image, execution terminated"
+ exit 1
+ else
+ docker_images="$DEFAULT_DOCKER_IMAGE_NAME"
+ fi
+ fi
+
+ docker_image_version=$(echo "$latest_snapshot_tag" | awk -F \. '{print $1"."$2"-SNAPSHOT-latest"}')
+ docker_image_name=$(echo "$docker_images" | sed -e "s/^.*://" -e "s/^.//" -e "s/.$//")
+
+ if \
+ curl -qL --silent \
+ "https://nexus3.onap.org/service/rest/repository/browse/docker.snapshot/v2/onap/$docker_image_name/tags/" |
+ grep -q "$docker_image_version"
+ then
+ echo "using \"$docker_image_name:$docker_image_version\" docker image for repo \"$repo\""
+ return
+ fi
+
+ docker_image_version="$latest_released_tag"
+ if \
+ curl -qL --silent \
+ "https://nexus3.onap.org/service/rest/repository/browse/docker.release/v2/onap/$docker_image_name/tags/" |
+ grep -q "$docker_image_version"
+ then
+ echo "using \"$docker_image_name:$docker_image_version\" docker image for repo \"$repo\""
+ return
+ fi
+
+ docker_image_version="$DEFAULT_DOCKER_IMAGE_VERSION"
+ if \
+ curl -qL --silent \
+ "https://nexus3.onap.org/service/rest/repository/browse/docker.release/v2/onap/$docker_image_name/tags/" |
+ grep -q "$docker_image_version"
+ then
+ echo "using \"$docker_image_name:$docker_image_version\" docker image for repo \"$repo\""
+ return
+ else
+ echo "docker image \"$docker_image_name:$docker_image_version\" not found for repo \"$repo\""
+ exit 1
+ fi
}
-export POLICY_MODELS_VERSION=$(getVersion models)
-echo POLICY_MODELS_VERSION="${POLICY_MODELS_VERSION}"
+getDockerVersion docker
+export POLICY_DOCKER_VERSION="$docker_image_version"
-export POLICY_API_VERSION=$(getVersion api)
-echo POLICY_API_VERSION="${POLICY_API_VERSION}"
+getDockerVersion models "'policy-models-simulator'" 2.6.4
+export POLICY_MODELS_VERSION="$docker_image_version"
-export POLICY_PAP_VERSION=$(getVersion pap)
-echo POLICY_PAP_VERSION="${POLICY_PAP_VERSION}"
+getDockerVersion api
+export POLICY_API_VERSION="$docker_image_version"
-export POLICY_XACML_PDP_VERSION=$(getVersion xacml-pdp)
-echo POLICY_XACML_PDP_VERSION="${POLICY_XACML_PDP_VERSION}"
+getDockerVersion pap
+export POLICY_PAP_VERSION="$docker_image_version"
-export POLICY_DROOLS_VERSION=$(getVersion drools-pdp)
-echo POLICY_DROOLS_VERSION="${POLICY_DROOLS_VERSION}"
+getDockerVersion apex-pdp
+export POLICY_APEX_PDP_VERSION="$docker_image_version"
-export POLICY_DROOLS_APPS_VERSION=$(getVersion drools-applications)
-echo POLICY_DROOLS_APPS_VERSION="${POLICY_DROOLS_APPS_VERSION}"
+getDockerVersion drools-pdp
+export POLICY_DROOLS_PDP_VERSION="$docker_image_version"
-export POLICY_APEX_PDP_VERSION=$(getVersion apex-pdp)
-echo POLICY_APEX_PDP_VERSION="${POLICY_APEX_PDP_VERSION}"
+getDockerVersion xacml-pdp
+export POLICY_XACML_PDP_VERSION="$docker_image_version"
-export POLICY_DISTRIBUTION_VERSION=$(getVersion distribution)
-echo POLICY_DISTRIBUTION_VERSION="${POLICY_DISTRIBUTION_VERSION}"
+getDockerVersion distribution
+export POLICY_DISTRIBUTION_VERSION="$docker_image_version"
-export POLICY_CLAMP_VERSION=$(getVersion clamp)
-echo POLICY_CLAMP_VERSION="${POLICY_CLAMP_VERSION}"
+getDockerVersion clamp
+export POLICY_CLAMP_VERSION="$docker_image_version"
-export POLICY_DOCKER_VERSION=$(getVersion docker)
-echo POLICY_DOCKER_VERSION="${POLICY_DOCKER_VERSION}"
+getDockerVersion gui
+export POLICY_GUI_VERSION="$docker_image_version"
-export POLICY_GUI_VERSION=$(getVersion gui)
-echo POLICY_GUI_VERSION="${POLICY_GUI_VERSION}"
+getDockerVersion drools-applications
+export POLICY_DROOLS_APPS_VERSION="$docker_image_version"