summaryrefslogtreecommitdiffstats
path: root/integration/src/main/scripts/release/updateParentRef.sh
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@est.tech>2022-06-17 10:44:27 +0100
committerliamfallon <liam.fallon@est.tech>2022-06-17 10:47:38 +0100
commitcd44921c7e00e699b27697d3e5be4fc3433b81a2 (patch)
treeb06c916c12e9075571f51b1978105357bb81900d /integration/src/main/scripts/release/updateParentRef.sh
parentb3223fd59ea60d98948e23073833a010c027a8a2 (diff)
Restructure scripts in policy-parent
- Moved the scripts into src/main/scripts - created src/main/resources - added pf_release_data.csv to src/main/resources, this file will be - added a n ew release phase to release the mdoels-simulator image pf_release_data.sh: Used to find the correct versions of images to use for the CSIT tests, the current lookup scripts can't cope with snapshots being deleted after they time out. Issue-ID: POLICY-4233 Change-Id: Idb5a4a624c06114f0f480c599e87f5596705ea07 Signed-off-by: liamfallon <liam.fallon@est.tech>
Diffstat (limited to 'integration/src/main/scripts/release/updateParentRef.sh')
-rwxr-xr-xintegration/src/main/scripts/release/updateParentRef.sh130
1 files changed, 130 insertions, 0 deletions
diff --git a/integration/src/main/scripts/release/updateParentRef.sh b/integration/src/main/scripts/release/updateParentRef.sh
new file mode 100755
index 00000000..0f72aa53
--- /dev/null
+++ b/integration/src/main/scripts/release/updateParentRef.sh
@@ -0,0 +1,130 @@
+#!/bin/bash
+
+#
+# ============LICENSE_START================================================
+# ONAP
+# =========================================================================
+# Copyright (C) 2021-2022 Nordix Foundation.
+# =========================================================================
+# 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
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ============LICENSE_END==================================================
+#
+
+set -e
+
+SCRIPT_NAME=$(basename "$0")
+
+# Use the bash internal OSTYPE variable to check for MacOS
+if [[ "$OSTYPE" == "darwin"* ]]
+then
+ SED="gsed"
+else
+ SED="sed"
+fi
+
+usage()
+{
+ echo ""
+ echo "$SCRIPT_NAME - update the parent reference in a POM file"
+ echo ""
+ echo " usage: $SCRIPT_NAME [-options]"
+ echo ""
+ echo " options"
+ echo " -h - this help message"
+ echo " -f pom_file - the POM file to update"
+ echo " -g group_id - the parent group ID"
+ echo " -a artifact_id - the parent artifact ID"
+ echo " -v version - the parent version"
+ exit 255;
+}
+
+while getopts "hf:g:a:v:" opt
+do
+ case $opt in
+ h)
+ usage
+ ;;
+ f)
+ pom_file=$OPTARG
+ ;;
+ g)
+ group_id=$OPTARG
+ ;;
+ a)
+ artifact_id=$OPTARG
+ ;;
+ v)
+ version=$OPTARG
+ ;;
+ \?)
+ usage
+ exit 1
+ ;;
+ :)
+ echo "Option -$OPTARG requires an argument." >&2
+ exit 1
+ ;;
+ esac
+done
+
+if [ $OPTIND -eq 1 ]
+then
+ echo "no arguments were specified"
+ usage
+fi
+
+if [ ! -f "$pom_file" ]
+then
+ echo "POM file '$pom_file' specified on '-f' flag not found"
+ exit 1
+fi
+
+if [ -z "$group_id" ]
+then
+ echo "group ID not specified on '-g' flag"
+ exit 1
+fi
+
+if [ -z "$artifact_id" ]
+then
+ echo "artifact ID not specified on '-a' flag"
+ exit 1
+fi
+
+if [ -z "$version" ]
+then
+ echo "version not specified on '-v' flag"
+ exit 1
+fi
+
+pom_lines=$(wc -l "$pom_file" | $SED 's/^[ \t]*//' | cut -f1 -d' ')
+parent_start_line=$(grep -n '^[\t ]*<parent>[\t ]*$' "$pom_file" | cut -f1 -d':')
+parent_end_line=$(grep -n '^[\t ]*</parent>[\t ]*$' "$pom_file" | cut -f1 -d':')
+
+pom_head_lines=$((parent_start_line-1))
+pom_tail_lines=$((pom_lines-parent_end_line))
+
+pom_temp_file=$(mktemp)
+
+{
+ head -$pom_head_lines "$pom_file"
+ echo " <parent>"
+ echo " <groupId>$group_id</groupId>"
+ echo " <artifactId>$artifact_id</artifactId>"
+ echo " <version>$version</version>"
+ echo " <relativePath />"
+ echo " </parent>"
+ tail -$pom_tail_lines "$pom_file"
+} > "$pom_temp_file"
+
+mv "$pom_temp_file" "$pom_file"