diff options
Diffstat (limited to 'integration/src/main/scripts')
-rwxr-xr-x | integration/src/main/scripts/release/bumpSnapshots.sh | 206 | ||||
-rwxr-xr-x | integration/src/main/scripts/release/generateCommit.sh | 159 | ||||
-rwxr-xr-x | integration/src/main/scripts/release/getReleaseData.sh | 191 | ||||
-rwxr-xr-x | integration/src/main/scripts/release/mkart.sh | 125 | ||||
-rwxr-xr-x | integration/src/main/scripts/release/mkdock.sh | 154 | ||||
-rwxr-xr-x | integration/src/main/scripts/release/newReleaseSnapshots.sh | 192 | ||||
-rwxr-xr-x | integration/src/main/scripts/release/releasePhase.sh | 431 | ||||
-rwxr-xr-x | integration/src/main/scripts/release/releaseRepo.sh | 181 | ||||
-rwxr-xr-x | integration/src/main/scripts/release/releaseRepoImages.sh | 179 | ||||
-rwxr-xr-x | integration/src/main/scripts/release/updateOomImages.sh | 184 | ||||
-rwxr-xr-x | integration/src/main/scripts/release/updateParentRef.sh | 130 | ||||
-rwxr-xr-x | integration/src/main/scripts/release/updateRefs.sh | 413 | ||||
-rwxr-xr-x | integration/src/main/scripts/reports/pf_status_report.sh | 120 |
13 files changed, 2665 insertions, 0 deletions
diff --git a/integration/src/main/scripts/release/bumpSnapshots.sh b/integration/src/main/scripts/release/bumpSnapshots.sh new file mode 100755 index 00000000..c67e81ff --- /dev/null +++ b/integration/src/main/scripts/release/bumpSnapshots.sh @@ -0,0 +1,206 @@ +#!/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") +repo_location="./" +release_data_file="./pf_release_data.csv" + +# Use the bash internal OSTYPE variable to check for MacOS +if [[ "$OSTYPE" == "darwin"* ]] +then + SED="gsed" +else + SED="sed" +fi + +declare -a pf_repos=( + "policy/parent" + "policy/docker" + "policy/common" + "policy/models" + "policy/api" + "policy/pap" + "policy/drools-pdp" + "policy/apex-pdp" + "policy/xacml-pdp" + "policy/distribution" + "policy/gui" + "policy/clamp" + "policy/drools-applications" +) + +usage() +{ + echo "" + echo "$SCRIPT_NAME - generate commits to bump the snapshot version and update references to snapshot references" + echo " on any repos that need to be bumped or updated" + echo "" + echo " usage: $SCRIPT_NAME [-options]" + echo "" + echo " options" + echo " -h - this help message" + echo " -d data_file - the policy release data file to use, defaults to '$release_data_file'" + echo " -l location - the location of the policy framework repos on the file system," + echo " defaults to '$repo_location'" + echo " -i issue-id - issue ID in the format POLICY-nnnn" + echo "" + echo " examples:" + echo " $SCRIPT_NAME -l /home/user/onap -d /home/user/data/pf_release_data.csv -i POLICY-1234" + echo " bump snapshots on the repos at location '/home/user/onap' using the release data" + echo " in the file '/home/user/data/pf_release_data.csv'" + exit 255; +} + +while getopts "hd:l:i:" opt +do + case $opt in + h) + usage + ;; + d) + release_data_file=$OPTARG + ;; + l) + repo_location=$OPTARG + ;; + i) + issue_id=$OPTARG + ;; + \?) + usage + exit 1 + ;; + esac +done + +if [ $OPTIND -eq 1 ] +then + echo "no arguments were specified" + usage +fi + +if [[ -z "$repo_location" ]] +then + echo "policy repo location not specified on -l flag" + exit 1 +fi + +if ! [ -d "$repo_location" ] +then + echo "policy repo location '$repo_location' not found" + exit 1 +fi + +if [[ -z "$release_data_file" ]] +then + echo "policy release data file not specified on -d flag" + exit 1 +fi + +if ! [ -f "$release_data_file" ] +then + echo "policy release data file '$release_data_file' not found" + exit 1 +fi + +if [ -z "$issue_id" ] +then + echo "issue_id not specified on -i flag" + exit 1 +fi + +if ! echo "$issue_id" | grep -Eq '^POLICY-[0-9]*$' +then + echo "issue ID is invalid, it should be of form 'POLICY-nnnn'" + exit 1 +fi + +for specified_repo in "${pf_repos[@]}" +do + # shellcheck disable=SC2034 + # shellcheck disable=SC2046 + read -r repo \ + latest_released_tag \ + latest_snapshot_tag \ + changed_files \ + docker_images \ + <<< $(grep "$specified_repo" "$release_data_file" | tr ',' ' ' ) + + if [ ! "$repo" = "$specified_repo" ] + then + echo "repo '$specified_repo' not found in file 'pf_release_data.csv'" + continue + fi + + next_release_version=${latest_snapshot_tag%-*} + + if [ "$latest_released_tag" = "$next_release_version" ] + then + major_version=$(echo "$next_release_version" | $SED -E 's/^([0-9]*)\.[0-9]*\.[0-9]*$/\1/') + minor_version=$(echo "$next_release_version" | $SED -E 's/^[0-9]*\.([0-9]*)\.[0-9]*$/\1/') + patch_version=$(echo "$next_release_version" | $SED -E 's/^[0-9]*\.[0-9]*\.([0-9]*)$/\1/') + # shellcheck disable=SC2004 + new_patch_version=$(($patch_version+1)) + + new_snapshot_tag="$major_version"."$minor_version"."$new_patch_version"-SNAPSHOT + + echo "updating snapshot version and references of repo $repo to $new_snapshot_tag . . ." + mvn -f "$repo_location/$repo" \ + "-DnewVersion=$new_snapshot_tag" versions:set \ + versions:update-child-modules versions:commit + + temp_file=$(mktemp) + + echo "updating snapshot version of repo $repo in $repo_location/$repo/version.properties" + $SED -e "s/patch=$patch_version/patch=$new_patch_version/" \ + "$repo_location/$repo/version.properties" > "$temp_file" + mv "$temp_file" "$repo_location/$repo/version.properties" + fi + + updateRefs.sh -pcmoxs -d "$release_data_file" -l "$repo_location" -r "$repo" + + if [ "$(git -C "$repo_location/$specified_repo" status | grep '^[ \t]*modified:[ \t]*pom.xml' > /dev/null 2>&1)" = 0 ] + then + references_updated=0 + else + references_updated=1 + fi + + if [ "$latest_released_tag" != "$next_release_version" ] && [ $references_updated -ne 0 ] + then + continue + fi + + echo "generating commit to update snapshot version and/or references of repo $repo . . ." + + generateCommit.sh \ + -l "$repo_location" \ + -r "$repo" \ + -i "$issue_id" \ + -e "Update snapshot and/or references of $repo to latest snapshots" \ + -m "$repo updated to its latest own and reference snapshots" + + echo "commit to update snapshot version and/or references of repo $repo generated" +done + diff --git a/integration/src/main/scripts/release/generateCommit.sh b/integration/src/main/scripts/release/generateCommit.sh new file mode 100755 index 00000000..a62cf493 --- /dev/null +++ b/integration/src/main/scripts/release/generateCommit.sh @@ -0,0 +1,159 @@ +#!/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================================================== +# + +SCRIPT_NAME=$(basename "$0") +repo_location="./" + +usage() +{ + echo "" + echo "$SCRIPT_NAME - generates a new commit or a patch on an existing commit for PF releases" + echo "" + echo " usage: $SCRIPT_NAME [-options]" + echo "" + echo " options" + echo " -h - this help message" + echo " -l location - the location of the policy framework repos on the file system," + echo " defaults to '$repo_location'" + echo " -r repo - the policy repo to which to commit" + echo " -i issue-id - issue ID in the format POLICY-nnnn" + echo " -e commit-header - the header for the commit" + echo " -m commit-message - the message body for the commit" + echo "" + echo " example:" + echo " $SCRIPT_NAME -l /home/git/onap -r policy/pap -i POLICY-1234 -e commit-header -m commit-message" + echo " create a new commit or update an existing commit on policy/pap with the given details" + exit 255; +} + +while getopts "hl:r:i:e:m:" opt +do + case $opt in + h) + usage + ;; + l) + repo_location=$OPTARG + ;; + r) + specified_repo=$OPTARG + ;; + i) + issue_id=$OPTARG + ;; + e) + commit_header=$OPTARG + ;; + m) + commit_message=$OPTARG + ;; + \?) + usage + exit 1 + ;; + esac +done + +if [ $OPTIND -eq 1 ] +then + echo "no arguments were specified" + usage +fi + +if [[ -z "$repo_location" ]] +then + echo "policy repo location not specified on -l flag" + exit 1 +fi +if ! [ -d "$repo_location" ] +then + echo "policy repo location '$repo_location' not found" + exit 1 +fi + +if [ -z "$specified_repo" ] +then + echo "repo not specified on -r flag" + exit 1 +fi + +if [ -z "$issue_id" ] +then + echo "issue_id not specified on -i flag" + exit 1 +fi + +if ! echo "$issue_id" | grep -Eq '^POLICY-[0-9]*$' +then + echo "issue ID is invalid, it should be of form 'POLICY-nnnn'" + exit 1 +fi + +if [ -z "$commit_header" ] +then + echo "commit_header not specified on -e flag" + exit 1 +fi + +if [ -z "$commit_message" ] +then + echo "commit_message not specified on -m flag" + exit 1 +fi + +git -C "$repo_location/$specified_repo" status | grep '^Your branch is up to date' > /dev/null 2>&1 +return_code=$? + +if [ $return_code -eq 0 ] +then + echo "generating commit '$commit_header' . . ." + + commit_msg_temp_file=$(mktemp) + { + echo "$commit_header" + echo "" + echo "$commit_message" + echo "" + echo "*** This commit is generated by a PF release script ***" + echo "" + echo "Issue-ID: $issue_id" + } > "$commit_msg_temp_file" + + git -C "$repo_location/$specified_repo" add . + git -C "$repo_location/$specified_repo" commit -s -F "$commit_msg_temp_file" + rm "$commit_msg_temp_file" + + echo "commit '$commit_header' generated" +else + echo "updating commit '$commit_header' . . ." + + git -C "$repo_location/$specified_repo" add . + git -C "$repo_location/$specified_repo" commit -as --amend --no-edit + + echo "commit '$commit_header' updated" +fi + +echo "sending commit '$commit_header' to gerrit . . ." +git -C "$repo_location/$specified_repo" review +echo "commit '$commit_header' sent to gerrit . . ." + + diff --git a/integration/src/main/scripts/release/getReleaseData.sh b/integration/src/main/scripts/release/getReleaseData.sh new file mode 100755 index 00000000..ff0df042 --- /dev/null +++ b/integration/src/main/scripts/release/getReleaseData.sh @@ -0,0 +1,191 @@ +#!/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") +repo_location="./" +release_data_file="./pf_release_data.csv" +branch="master" + +# Use the bash internal OSTYPE variable to check for MacOS +if [[ "$OSTYPE" == "darwin"* ]] +then + SED="gsed" +else + SED="sed" +fi + +declare -a pf_repos=( + "policy/parent" + "policy/docker" + "policy/common" + "policy/models" + "policy/api" + "policy/pap" + "policy/apex-pdp" + "policy/drools-pdp" + "policy/xacml-pdp" + "policy/distribution" + "policy/clamp" + "policy/gui" + "policy/drools-applications" +) + +usage() +{ + echo "" + echo "$SCRIPT_NAME - gets information from the checked out Policy Framework repos for the release process" + echo "" + echo " usage: $SCRIPT_NAME [-options]" + echo "" + echo " options" + echo " -h - this help message" + echo " -b branch - the branch to release on, defaults to '$branch'" + echo " -d data_file - the policy release data file to create, defaults to '$release_data_file'" + echo " -l location - the location of the policy framework repos on the file system," + echo " defaults to '$repo_location'" + exit 255; +} + +while getopts "hb:d:l:" opt +do + case $opt in + h) + usage + ;; + b) + branch=$OPTARG + ;; + d) + release_data_file=$OPTARG + ;; + l) + repo_location=$OPTARG + ;; + \?) + usage + exit 1 + ;; + esac +done + +if [[ -z "$repo_location" ]] +then + echo "policy repo location not specified on -l flag" + exit 1 +fi + +if [[ -z "$branch" ]] +then + echo "policy branch not specified on -b flag" + exit 1 +fi + +if ! [ -d "$repo_location" ] +then + echo "policy repo location '$repo_location' not found" + exit 1 +fi + +if [[ -z "$release_data_file" ]] +then + echo "policy release data file not specified on -d flag" + exit 1 +fi + +update_repos() { + echo "updating the policy framework data from '$repo_location' to data file '$release_data_file' . . ." + + for repo in "${pf_repos[@]}" + do + echo "updating data from repo $repo branch $branch to data file '$release_data_file' . . ." + + if [ -d "$repo_location/$repo" ] + then + echo "updating repository '$repo' . . ." + git -C "$repo_location/$repo" checkout -- . + git -C "$repo_location/$repo" checkout "$branch" + git -C "$repo_location/$repo" pull + git -C "$repo_location/$repo" rebase + git -C "$repo_location/$repo" fetch --tags + else + echo "repo $repo does not exist" + exit 1 + fi + echo "data from repo $repo updated to data file '$release_data_file' . . ." + done + + echo "policy framework data from '$repo_location' updated to data file '$release_data_file' . . ." +} + +get_tags() { + echo "Repo, Last Tag Version,Snapshot Version,Changed Files,Docker Images" + echo "Repo, Last Tag Version,Snapshot Version,Changed Files,Docker Images" > "$release_data_file" + for repo in "${pf_repos[@]}" + do + latest_snapshot_tag=$(mvn -f "$repo_location/$repo" clean | \ + grep "SNAPSHOT" | \ + tail -1 | \ + $SED -r 's/^.* ([0-9]*\.[0-9]*\.[0-9]*-SNAPSHOT).*$/\1/') + + if [[ $branch == *master ]] + then + latest_released_tag=$(git -C "$repo_location/$repo" tag | \ + grep '^[0-9]*\.[0-9]*\.[0-9]*$' | \ + sort -V | \ + tail -1) + else + # shellcheck disable=SC2001 + latest_snapshot_major_minor=$(echo "$latest_snapshot_tag" | sed 's/\.[0-9]*-SNAPSHOT$//') + latest_released_tag=$(git -C "$repo_location/$repo" tag | \ + grep '^[0-9]*\.[0-9]*\.[0-9]*$' | \ + grep "$latest_snapshot_major_minor" | \ + sort -V | \ + tail -1) + fi + + changed_files=$(git -C "$repo_location/$repo" diff --name-only "$latest_released_tag" "$branch" | \ + grep -v 'pom.xml$' | \ + grep -v '^version.properties$' | \ + grep -v "^releases/$latest_released_tag.yaml$" | \ + grep -cv "^releases/$latest_released_tag-container.yaml$" | \ + $SED 's/^[[:space:]]*//g') + + latest_container_yaml=$(find "$repo_location/$repo/releases" -name "*container.yaml" | sort | tail -1) + if [ "$latest_container_yaml" != "" ] + then + docker_images=$(grep '\- name:' "$latest_container_yaml" | \ + $SED -e 's/\- //g' -e 's/\://g' -e "s/\'//g" -e 's/^[[:space:]]*//g' -e 's/^name //' | \ + tr '\n' ':' | \ + $SED 's/:$//') + else + docker_images="" + fi + + echo "$repo,$latest_released_tag,$latest_snapshot_tag,$changed_files,$docker_images" + echo "$repo,$latest_released_tag,$latest_snapshot_tag,$changed_files,$docker_images" >> "$release_data_file" + done +} + +update_repos +get_tags diff --git a/integration/src/main/scripts/release/mkart.sh b/integration/src/main/scripts/release/mkart.sh new file mode 100755 index 00000000..2243e293 --- /dev/null +++ b/integration/src/main/scripts/release/mkart.sh @@ -0,0 +1,125 @@ +#!/bin/bash + +# +# ============LICENSE_START================================================ +# ONAP +# ========================================================================= +# Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. +# Modifications Copyright (C) 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================================================== +# + +# +# This creates the x.y.z.yaml file for releasing (java) artifacts. +# It should be executed from somewhere within the "git" repo to be +# released. Assumes the following: +# - the branch to be released is currently checked out +# - the latest maven-stage jenkins job is the one to be released +# - the defaultbranch within the .gitreview file is set to the +# branch to be released +# +# This uses xmllint, which is part of the libxml2-utils package. +# +# If behind a firewall, then http_proxy must be set so that curl +# can get through the firewall. +# + +# Use the bash internal OSTYPE variable to check for MacOS +if [[ "$OSTYPE" == "darwin"* ]] +then + SED="gsed" +else + SED="sed" +fi + +set -e + +has_docker_images=false + +if [ "$1" == "-d" ] +then + has_docker_images=true + shift +fi + +TOPDIR=$(git rev-parse --show-toplevel) +if [ -z "${TOPDIR}" ]; then + echo "cannot determine top of 'git' repo" >&2 + exit 1 +fi + +BRANCH=$(awk -F= '$1 == "defaultbranch" { print $2 }' "${TOPDIR}/.gitreview") +if [ -z "${BRANCH}" ]; then + echo "cannot extract default branch from ${TOPDIR}/.gitreview" >&2 + exit 1 +fi +echo Branch: "${BRANCH}" + +PROJECT=$(awk -F= '$1 == "project" { print $2 }' "${TOPDIR}/.gitreview" | + $SED 's/.git$//') +if [ -z "${PROJECT}" ]; then + echo "cannot extract project from ${TOPDIR}/.gitreview" >&2 + exit 1 +fi +echo Project: "${PROJECT}" +DPROJ=$(echo "${PROJECT}" | $SED 's!/!-!') + +VERSION=$( + xmllint --xpath \ + '/*[local-name()="project"]/*[local-name()="version"]/text()' \ + "${TOPDIR}/pom.xml" | + $SED 's!-SNAPSHOT!!' + ) +if [ -z "${VERSION}" ]; then + echo "cannot extract version from ${TOPDIR}/pom.xml" >&2 + exit 1 +fi +echo "Version: ${VERSION}" + +prefix='https://jenkins.onap.org/view/policy/job/' +STAGE_ID=$( + curl --silent "${prefix}${DPROJ}-maven-stage-${BRANCH}/" | + grep "Last completed build" | + $SED -e 's!.*Last completed build .#!!' -e 's!).*!!' | + head -1 + ) +if [ -z "${STAGE_ID}" ]; then + echo "cannot extract last maven stage ID from jenkins" >&2 + exit 1 +fi +STAGE_ID="${DPROJ}-maven-stage-${BRANCH}/${STAGE_ID}/" +echo Stage ID: "${STAGE_ID}" + +prefix='https://jenkins.onap.org/view/policy/job/' +JOB_OUT=$(curl --silent "${prefix}${STAGE_ID}/consoleFull") +echo "${JOB_OUT}" | grep -q "Finished: SUCCESS" +# shellcheck disable=SC2181 +if [ $? -ne 0 ]; then + echo "last jenkins build has not completed successfully" >&2 + exit 1 +fi + +echo Creating "${TOPDIR}/releases/${VERSION}.yaml" + +echo "distribution_type: 'maven'" > "${TOPDIR}/releases/${VERSION}.yaml" +echo "version: '${VERSION}'" >> "${TOPDIR}/releases/${VERSION}.yaml" +echo "project: '${DPROJ}'" >> "${TOPDIR}/releases/${VERSION}.yaml" + +if [ $has_docker_images = true ] +then + echo "tag_release: false" >> "${TOPDIR}/releases/${VERSION}.yaml" +fi + +echo "log_dir: '${STAGE_ID}'" >> "${TOPDIR}/releases/${VERSION}.yaml" diff --git a/integration/src/main/scripts/release/mkdock.sh b/integration/src/main/scripts/release/mkdock.sh new file mode 100755 index 00000000..0df4abad --- /dev/null +++ b/integration/src/main/scripts/release/mkdock.sh @@ -0,0 +1,154 @@ +#!/bin/bash + +# +# ============LICENSE_START================================================ +# ONAP +# ========================================================================= +# Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. +# Modifications Copyright (C) 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================================================== +# + +# +# This creates the x.y.z-container.yaml file for releasing a docker image. +# It should be executed from somewhere within the "git" repo to be +# released. Assumes the following: +# - the latest commit is at the top of the "git log" +# - the branch to be released is currently checked out +# - the latest maven-docker-stage jenkins job is the one to be released +# - the defaultbranch within the .gitreview file is set to the +# branch to be released +# +# This uses xmllint, which is part of the libxml2-utils package. +# +# If behind a firewall, then http_proxy must be set so that curl +# can get through the firewall. +# + +set -e + +# Use the bash internal OSTYPE variable to check for MacOS +if [[ "$OSTYPE" == "darwin"* ]] +then + SED="gsed" +else + SED="sed" +fi + +# shellcheck disable=SC2166 +if [ $# -lt 1 -o "$1" = "-?" ] +then + echo "arg(s): docker-container-name1 docker-container-name2 ..." >&2 + exit 1 +fi + +TOPDIR=$(git rev-parse --show-toplevel) +if [ -z "${TOPDIR}" ]; then + echo "cannot determine top of 'git' repo" >&2 + exit 1 +fi + +BRANCH=$(awk -F= '$1 == "defaultbranch" { print $2 }' "${TOPDIR}/.gitreview") +if [ -z "${BRANCH}" ]; then + echo "cannot extract default branch from ${TOPDIR}/.gitreview" >&2 + exit 1 +fi +echo "Branch: ${BRANCH}" + +PROJECT=$(awk -F= '$1 == "project" { print $2 }' "${TOPDIR}/.gitreview" | + $SED 's/.git$//') +if [ -z "${PROJECT}" ]; then + echo "cannot extract project from ${TOPDIR}/.gitreview" >&2 + exit 1 +fi +echo "Project: ${PROJECT}" +DPROJ=$(echo "${PROJECT}" | $SED 's!/!-!') + +RELEASE=$( + xmllint --xpath \ + '/*[local-name()="project"]/*[local-name()="version"]/text()' \ + "${TOPDIR}/pom.xml" | + $SED 's!-SNAPSHOT!!' + ) +if [ -z "${RELEASE}" ]; then + echo "cannot extract release from ${TOPDIR}/pom.xml" >&2 + exit 1 +fi +echo "Release: ${RELEASE}" + +REF_ID=$(git log | grep commit | head -1 | awk '{ print $2 }') +if [ -z "${REF_ID}" ]; then + echo "cannot extract ref from 'git log'" >&2 + exit 1 +fi +echo "Ref: ${REF_ID}" + +prefix='https://jenkins.onap.org/view/policy/job/' +STAGE_ID=$( + curl --silent "${prefix}${DPROJ}-maven-docker-stage-${BRANCH}/" | + grep "Last completed build" | + $SED -e 's!.*Last completed build .#!!' -e 's!).*!!' | + head -1 + ) +if [ -z "${STAGE_ID}" ]; then + echo "cannot extract last docker stage ID from jenkins" >&2 + exit 1 +fi +STAGE_ID=${DPROJ}-maven-docker-stage-${BRANCH}/${STAGE_ID} +echo "Stage ID: ${STAGE_ID}" + +prefix='https://jenkins.onap.org/view/policy/job/' +JOB_OUT=$(curl --silent "${prefix}${STAGE_ID}/consoleFull") +echo "${JOB_OUT}" | grep -q "Finished: SUCCESS" +# shellcheck disable=SC2181 +if [ $? -ne 0 ]; then + echo "last docker build has not completed successfully" >&2 + exit 1 +fi + +echo "Creating ${TOPDIR}/releases/${RELEASE}-container.yaml" +cat >"${TOPDIR}/releases/${RELEASE}-container.yaml" <<EOT +distribution_type: 'container' +container_release_tag: '${RELEASE}' +project: '${DPROJ}' +log_dir: '${STAGE_ID}' +ref: ${REF_ID} +containers: +EOT + +for CONT_NAME in "$@" +do + VERSION=$( + echo "${JOB_OUT}" | + awk " + /Successfully tagged onap/ { found = 0 } + /Successfully tagged onap\/${CONT_NAME}:/ { found = 1 } + found == 1 && /Tag with/ { print } + " | + head -1 | + $SED 's!.*Tag with!!' | + cut -d, -f2 + ) + if [ -z "${VERSION}" ]; then + echo "cannot extract ${CONT_NAME} version from jenkins build output" >&2 + exit 1 + fi + echo "${CONT_NAME} version: ${VERSION}" + + cat >>"${TOPDIR}/releases/${RELEASE}-container.yaml" <<EOT_LOOP + - name: '${CONT_NAME}' + version: '${VERSION}' +EOT_LOOP +done diff --git a/integration/src/main/scripts/release/newReleaseSnapshots.sh b/integration/src/main/scripts/release/newReleaseSnapshots.sh new file mode 100755 index 00000000..3e4ab2bb --- /dev/null +++ b/integration/src/main/scripts/release/newReleaseSnapshots.sh @@ -0,0 +1,192 @@ +#!/bin/bash + +# +# ============LICENSE_START================================================ +# ONAP +# ========================================================================= +# Copyright (C) 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") +repo_location="./" +release_data_file="./pf_release_data.csv" + +# Use the bash internal OSTYPE variable to check for MacOS +if [[ "$OSTYPE" == "darwin"* ]] +then + SED="gsed" +else + SED="sed" +fi + +declare -a pf_repos=( + "policy/parent" + "policy/docker" + "policy/common" + "policy/models" + "policy/api" + "policy/pap" + "policy/drools-pdp" + "policy/apex-pdp" + "policy/xacml-pdp" + "policy/distribution" + "policy/gui" + "policy/clamp" + "policy/drools-applications" +) + +usage() +{ + echo "" + echo "$SCRIPT_NAME - on release changes, generate commits to set the snapshot version and update" + echo " references on any repos that reference other repos" + echo "" + echo " usage: $SCRIPT_NAME [-options]" + echo "" + echo " options" + echo " -h - this help message" + echo " -d data_file - the policy release data file to use, defaults to '$release_data_file'" + echo " -l location - the location of the policy framework repos on the file system," + echo " defaults to '$repo_location'" + echo " -i issue-id - issue ID in the format POLICY-nnnn" + echo "" + echo " examples:" + echo " $SCRIPT_NAME -l /home/user/onap -d /home/user/data/pf_release_data.csv -i POLICY-1234" + echo " set snapshots on the repos at location '/home/user/onap' using the release data" + echo " in the file '/home/user/data/pf_release_data.csv'" + exit 255; +} + +while getopts "hd:l:i:" opt +do + case $opt in + h) + usage + ;; + d) + release_data_file=$OPTARG + ;; + l) + repo_location=$OPTARG + ;; + i) + issue_id=$OPTARG + ;; + \?) + usage + exit 1 + ;; + esac +done + +if [ $OPTIND -eq 1 ] +then + echo "no arguments were specified" + usage +fi + +if [[ -z "$repo_location" ]] +then + echo "policy repo location not specified on -l flag" + exit 1 +fi + +if ! [ -d "$repo_location" ] +then + echo "policy repo location '$repo_location' not found" + exit 1 +fi + +if [[ -z "$release_data_file" ]] +then + echo "policy release data file not specified on -d flag" + exit 1 +fi + +if ! [ -f "$release_data_file" ] +then + echo "policy release data file '$release_data_file' not found" + exit 1 +fi + +if [ -z "$issue_id" ] +then + echo "issue_id not specified on -i flag" + exit 1 +fi + +if ! echo "$issue_id" | grep -Eq '^POLICY-[0-9]*$' +then + echo "issue ID is invalid, it should be of form 'POLICY-nnnn'" + exit 1 +fi + +for specified_repo in "${pf_repos[@]}" +do + # shellcheck disable=SC2034 + # shellcheck disable=SC2046 + read -r repo \ + latest_released_tag \ + latest_snapshot_tag \ + changed_files \ + docker_images \ + <<< $(grep "$specified_repo" "$release_data_file" | tr ',' ' ' ) + + if [ ! "$repo" = "$specified_repo" ] + then + echo "repo '$specified_repo' not found in file 'pf_release_data.csv'" + continue + fi + + next_release_version=${latest_snapshot_tag%-*} + + major_version=$(echo "$latest_released_tag" | $SED -E 's/^([0-9]*)\.[0-9]*\.[0-9]*$/\1/') + minor_version=$(echo "$latest_released_tag" | $SED -E 's/^[0-9]*\.([0-9]*)\.[0-9]*$/\1/') + patch_version=$(echo "$next_release_version" | $SED -E 's/^[0-9]*\.[0-9]*\.([0-9]*)$/\1/') + # shellcheck disable=SC2004 + new_minor_version=$(($minor_version+1)) + + new_snapshot_tag="$major_version"."$new_minor_version".0-SNAPSHOT + + echo "updating snapshot version and references of repo $repo to $new_snapshot_tag . . ." + mvn -f "$repo_location/$repo" \ + "-DnewVersion=$new_snapshot_tag" versions:set \ + versions:update-child-modules versions:commit + + temp_file=$(mktemp) + + echo "set snapshot version of repo $repo in $repo_location/$repo/version.properties" + $SED \ + -e "s/minor=$minor_version/minor=$new_minor_version/" \ + -e "s/patch=$patch_version/patch=0/" \ + "$repo_location/$repo/version.properties" \ + > "$temp_file" + mv "$temp_file" "$repo_location/$repo/version.properties" + + updateRefs.sh -pcmoxs -d "$release_data_file" -l "$repo_location" -r "$repo" + + generateCommit.sh \ + -l "$repo_location" \ + -r "$repo" \ + -i "$issue_id" \ + -e "Set snapshot and/or references of $repo for new release" \ + -m "$repo updated to its latest own and reference snapshots" + + echo "commit to set snapshot version and/or references of repo $repo generated" +done + diff --git a/integration/src/main/scripts/release/releasePhase.sh b/integration/src/main/scripts/release/releasePhase.sh new file mode 100755 index 00000000..e606ffb5 --- /dev/null +++ b/integration/src/main/scripts/release/releasePhase.sh @@ -0,0 +1,431 @@ +#!/bin/bash + +# +# ============LICENSE_START================================================ +# ONAP +# ========================================================================= +# Copyright (C) 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") +repo_location="./" +release_data_file="./pf_release_data.csv" + +usage() +{ + echo "" + echo "$SCRIPT_NAME - execute a certain policy framework release phase" + echo "" + echo " usage: $SCRIPT_NAME [-options]" + echo "" + echo " options" + echo " -h - this help message" + echo " -d data_file - the policy release data file to use, defaults to '$release_data_file'" + echo " -l location - the location of the policy framework repos on the file system," + echo " defaults to '$repo_location'" + echo " -i issue-id - issue ID in the format POLICY-nnnn" + echo " -p phase - the release phase, a positive integer" + echo "" + echo " examples:" + echo " $SCRIPT_NAME -l /home/user/onap -d /home/user/data/pf_release_data.csv -i POLICY-1234 -p 3" + echo " perform release phase 3 on the repos at location '/home/user/onap' using the release data" + echo " in the file '/home/user/data/pf_release_data.csv'" + exit 255; +} + +while getopts "hd:l:i:p:" opt +do + case $opt in + h) + usage + ;; + d) + release_data_file=$OPTARG + ;; + l) + repo_location=$OPTARG + ;; + i) + issue_id=$OPTARG + ;; + p) + release_phase=$OPTARG + ;; + \?) + usage + exit 1 + ;; + esac +done + +if [ $OPTIND -eq 1 ] +then + echo "no arguments were specified" + usage +fi + +if [[ -z "$repo_location" ]] +then + echo "policy repo location not specified on -l flag" + exit 1 +fi + +if ! [ -d "$repo_location" ] +then + echo "policy repo location '$repo_location' not found" + exit 1 +fi + +if [[ -z "$release_data_file" ]] +then + echo "policy release data file not specified on -d flag" + exit 1 +fi + +if ! [ -f "$release_data_file" ] +then + echo "policy release data file '$release_data_file' not found" + exit 1 +fi + +if [ -z "$issue_id" ] +then + echo "issue_id not specified on -i flag" + exit 1 +fi + +if ! echo "$issue_id" | grep -Eq '^POLICY-[0-9]*$' +then + echo "issue ID is invalid, it should be of form 'POLICY-nnnn'" + exit 1 +fi + +if [ -z "$release_phase" ] +then + echo "release_phase not specified on -p flag" + exit 1 +fi + +if ! [[ "$release_phase" =~ ^[0-9]+$ ]] +then + echo "release_phase is invalid, it should be a positive integer" + exit 1 +fi + +release_phase_1() { + echo "Updating parent references in the parent pom and generating commit . . ." + updateRefs.sh -d "$release_data_file" -l "$repo_location" -r policy/parent -p + generateCommit.sh \ + -l "$repo_location" \ + -r policy/parent \ + -i "$issue_id" \ + -e "update parent references in policy/parent pom" \ + -m "updated the parent references in the policy/parent pom" + echo "Updated parent references in the parent pom and generated commit" +} + +release_phase_2() { + echo "Generating artifact release yaml file and commit for policy/parent . . ." + releaseRepo.sh -d "$release_data_file" -l "$repo_location" -r policy/parent -i "$issue_id" + echo "Generated artifact release yaml file and commit for policy/parent" +} + +release_phase_3() { + echo "Updating snapshots for policy/parent, updating references on policy/docker and policy/common . . ." + bumpSnapshots.sh \ + -d "$release_data_file" \ + -l "$repo_location" \ + -i "$issue_id" + updateRefs.sh \ + -p \ + -d "$release_data_file" \ + -l "$repo_location" \ + -r "policy/docker" + updateRefs.sh \ + -p \ + -d "$release_data_file" \ + -l "$repo_location" \ + -r "policy/common" + generateCommit.sh \ + -l "$repo_location" \ + -r "policy/docker" \ + -i "$issue_id" \ + -e "update parent references in policy/docker pom" \ + -m "updated the parent references in the policy/docker pom" + generateCommit.sh \ + -l "$repo_location" \ + -r "policy/common" \ + -i "$issue_id" \ + -e "update parent references in policy/common pom" \ + -m "updated the parent references in the policy/common pom" + echo "Updated snapshots for policy/parent, updating references on policy/docker and policy/common" +} + +release_phase_4() { + echo "Generating artifact release yaml file and commit for policy/common . . ." + releaseRepo.sh -d "$release_data_file" -l "$repo_location" -r policy/common -i "$issue_id" + echo "Generated artifact release yaml file and commit for policy/common" + + echo "Generating docker release yaml file and commit for policy/docker . . ." + releaseRepoImages.sh -d "$release_data_file" -l "$repo_location" -r policy/docker -i "$issue_id" + echo "Generated docker release yaml file and commit for policy/docker" +} + +release_phase_5() { + echo "Updating snapshots for policy/common and policy/docker, updating references on policy/models . . ." + bumpSnapshots.sh \ + -d "$release_data_file" \ + -l "$repo_location" \ + -i "$issue_id" + updateRefs.sh \ + -pc \ + -d "$release_data_file" \ + -l "$repo_location" \ + -r "policy/models" + generateCommit.sh \ + -l "$repo_location" \ + -r "policy/models" \ + -i "$issue_id" \ + -e "update parent,common references in policy/models pom" \ + -m "updated the parent and common references in the policy/models pom" + echo "Updated snapshots for policy/common and policy/docker, updated references on policy/models" +} + +release_phase_6() { + echo "Generating artifact release yaml file and commit for policy/models . . ." + releaseRepo.sh -d "$release_data_file" -l "$repo_location" -r policy/models -i "$issue_id" + echo "Generated artifact release yaml file and commit for policy/models" +} + +release_phase_7() { + echo "Generating docker release yaml file and commit for policy/models . . ." + releaseRepoImages.sh -d "$release_data_file" -l "$repo_location" -r policy/models -i "$issue_id" + echo "Generated docker release yaml file and commit for policy/models" +} + +release_phase_8() { + echo "Updating snapshots for policy/models, updating references on other repos . . ." + bumpSnapshots.sh \ + -d "$release_data_file" \ + -l "$repo_location" \ + -i "$issue_id" + updateRefs.sh \ + -pcmk \ + -d "$release_data_file" \ + -l "$repo_location" \ + -r "policy/apex-pdp" + updateRefs.sh \ + -pcmk \ + -d "$release_data_file" \ + -l "$repo_location" \ + -r "policy/api" + updateRefs.sh \ + -pcmk \ + -d "$release_data_file" \ + -l "$repo_location" \ + -r "policy/clamp" + updateRefs.sh \ + -pcmk \ + -d "$release_data_file" \ + -l "$repo_location" \ + -r "policy/distribution" + updateRefs.sh \ + -pcmk \ + -d "$release_data_file" \ + -l "$repo_location" \ + -r "policy/drools-pdp" + updateRefs.sh \ + -pcmk \ + -d "$release_data_file" \ + -l "$repo_location" \ + -r "policy/pap" + updateRefs.sh \ + -pcmk \ + -d "$release_data_file" \ + -l "$repo_location" \ + -r "policy/xacml-pdp" + generateCommit.sh \ + -l "$repo_location" \ + -r "policy/apex-pdp" \ + -i "$issue_id" \ + -e "update references in policy/apex-pdp pom" \ + -m "updated references in the policy/apex-pdp pom" + generateCommit.sh \ + -l "$repo_location" \ + -r "policy/api" \ + -i "$issue_id" \ + -e "update references in policy/api pom" \ + -m "updated references in the policy/api pom" + generateCommit.sh \ + -l "$repo_location" \ + -r "policy/clamp" \ + -i "$issue_id" \ + -e "update references in policy/clamp pom" \ + -m "updated references in the policy/clamp pom" + generateCommit.sh \ + -l "$repo_location" \ + -r "policy/distribution" \ + -i "$issue_id" \ + -e "update references in policy/distribution pom" \ + -m "updated references in the policy/distribution pom" + generateCommit.sh \ + -l "$repo_location" \ + -r "policy/drools-pdp" \ + -i "$issue_id" \ + -e "update references in policy/drools-pdp pom" \ + -m "updated references in the policy/drools-pdp pom" + generateCommit.sh \ + -l "$repo_location" \ + -r "policy/pap" \ + -i "$issue_id" \ + -e "update references in policy/pap pom" \ + -m "updated references in the policy/pap pom" + generateCommit.sh \ + -l "$repo_location" \ + -r "policy/xacml-pdp" \ + -i "$issue_id" \ + -e "update references in policy/xacml-pdp pom" \ + -m "updated references in the policy/xacml-pdp pom" + echo "Updated snapshots for policy/models, updated references on other repos" +} + +release_phase_9() { + echo "Generating artifact release yaml file and commit for repos . . ." + releaseRepo.sh -d "$release_data_file" -l "$repo_location" -r policy/apex-pdp -i "$issue_id" + releaseRepo.sh -d "$release_data_file" -l "$repo_location" -r policy/api -i "$issue_id" + releaseRepo.sh -d "$release_data_file" -l "$repo_location" -r policy/clamp -i "$issue_id" + releaseRepo.sh -d "$release_data_file" -l "$repo_location" -r policy/distribution -i "$issue_id" + releaseRepo.sh -d "$release_data_file" -l "$repo_location" -r policy/drools-pdp -i "$issue_id" + releaseRepo.sh -d "$release_data_file" -l "$repo_location" -r policy/pap -i "$issue_id" + releaseRepo.sh -d "$release_data_file" -l "$repo_location" -r policy/xacml-pdp -i "$issue_id" + echo "Generated artifact release yaml file and commit for repos" +} + +release_phase_10() { + echo "Generating docker release yaml file and commit for repos . . ." + releaseRepoImages.sh -d "$release_data_file" -l "$repo_location" -r policy/apex-pdp -i "$issue_id" + releaseRepoImages.sh -d "$release_data_file" -l "$repo_location" -r policy/api -i "$issue_id" + releaseRepoImages.sh -d "$release_data_file" -l "$repo_location" -r policy/clamp -i "$issue_id" + releaseRepoImages.sh -d "$release_data_file" -l "$repo_location" -r policy/distribution -i "$issue_id" + releaseRepoImages.sh -d "$release_data_file" -l "$repo_location" -r policy/drools-pdp -i "$issue_id" + releaseRepoImages.sh -d "$release_data_file" -l "$repo_location" -r policy/pap -i "$issue_id" + releaseRepoImages.sh -d "$release_data_file" -l "$repo_location" -r policy/xacml-pdp -i "$issue_id" + echo "Generated docker release yaml file and commit for repos" +} + +release_phase_11() { + echo "Updating snapshots for repos, updating references on policy/drools-applications, policy/gui . . ." + bumpSnapshots.sh \ + -d "$release_data_file" \ + -l "$repo_location" \ + -i "$issue_id" + updateRefs.sh \ + -pcmok \ + -d "$release_data_file" \ + -l "$repo_location" \ + -r "policy/drools-applications" + updateRefs.sh \ + -pcmxk \ + -d "$release_data_file" \ + -l "$repo_location" \ + -r "policy/gui" + generateCommit.sh \ + -l "$repo_location" \ + -r "policy/drools-applications" \ + -i "$issue_id" \ + -e "update references in policy/drools-applications pom" \ + -m "updated references in the policy/drools-applications pom" + generateCommit.sh \ + -l "$repo_location" \ + -r "policy/gui" \ + -i "$issue_id" \ + -e "update references in policy/gui pom" \ + -m "updated references in the policy/gui pom" + echo "Updated snapshots for repos, updated references on policy/drools-applications, policy/gui" +} + +release_phase_12() { + echo "Generating artifact release yaml file and commit for policy/drools-applications . . ." + releaseRepo.sh -d "$release_data_file" -l "$repo_location" -r policy/drools-applications -i "$issue_id" + releaseRepo.sh -d "$release_data_file" -l "$repo_location" -r policy/gui -i "$issue_id" + echo "Generated artifact release yaml file and commit for policy/drools-applications" +} + +release_phase_13() { + echo "Generating docker release yaml file and commit for policy/drools-applications . . ." + releaseRepoImages.sh -d "$release_data_file" -l "$repo_location" -r policy/drools-applications -i "$issue_id" + releaseRepoImages.sh -d "$release_data_file" -l "$repo_location" -r policy/gui -i "$issue_id" + echo "Generated docker release yaml file and commit for policy/drools-applications" +} + +release_phase_14() { + echo "Updating snapshots on policy/drools-applications, policy/gui . . ." + bumpSnapshots.sh \ + -d "$release_data_file" \ + -l "$repo_location" \ + -i "$issue_id" + echo "Updated snapshots on policy/drools-applications, policy/gui" +} + +case "$release_phase" in + +1) release_phase_1 + ;; + +2) release_phase_2 + ;; + +3) release_phase_3 + ;; + +4) release_phase_4 + ;; + +5) release_phase_5 + ;; + +6) release_phase_6 + ;; + +7) release_phase_7 + ;; + +8) release_phase_8 + ;; + +9) release_phase_9 + ;; + +10) release_phase_10 + ;; + +11) release_phase_11 + ;; + +12) release_phase_12 + ;; + +13) release_phase_13 + ;; + +14) release_phase_14 + ;; + +*) echo "specified release phase '$release_phase' is invalid" + ;; +esac diff --git a/integration/src/main/scripts/release/releaseRepo.sh b/integration/src/main/scripts/release/releaseRepo.sh new file mode 100755 index 00000000..a0c48efe --- /dev/null +++ b/integration/src/main/scripts/release/releaseRepo.sh @@ -0,0 +1,181 @@ +#!/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================================================== +# + +SCRIPT_NAME=$(basename "$0") +repo_location="./" +release_data_file="./pf_release_data.csv" + +usage() +{ + echo "" + echo "$SCRIPT_NAME - release the specified repository by generating the release yaml file and the release commit" + echo "" + echo " usage: $SCRIPT_NAME [-options]" + echo "" + echo " options" + echo " -h - this help message" + echo " -d data_file - the policy release data file to use, defaults to '$release_data_file'" + echo " -l location - the location of the policy framework repos on the file system," + echo " defaults to '$repo_location'" + echo " -r repo - the policy repo to release" + echo " -i issue-id - issue ID in the format POLICY-nnnn" + echo "" + echo " examples:" + echo " $SCRIPT_NAME -l /home/user/onap -d /home/user/data/pf_release_data.csv -r policy/common -i POLICY-1234" + echo " release the 'policy/common' repo at location '/home/user/onap' using the release data" + echo " in the file '/home/user/data/pf_release_data.csv'" + exit 255; +} + +while getopts "hd:l:r:i:" opt +do + case $opt in + h) + usage + ;; + d) + release_data_file=$OPTARG + ;; + l) + repo_location=$OPTARG + ;; + r) + specified_repo=$OPTARG + ;; + i) + issue_id=$OPTARG + ;; + \?) + usage + exit 1 + ;; + esac +done + +if [ $OPTIND -eq 1 ] +then + echo "no arguments were specified" + usage +fi + +if [[ -z "$repo_location" ]] +then + echo "policy repo location not specified on -l flag" + exit 1 +fi + +if ! [ -d "$repo_location" ] +then + echo "policy repo location '$repo_location' not found" + exit 1 +fi + +if [[ -z "$release_data_file" ]] +then + echo "policy release data file not specified on -d flag" + exit 1 +fi + +if ! [ -f "$release_data_file" ] +then + echo "policy release data file '$release_data_file' not found" + exit 1 +fi + +if [ -z "$specified_repo" ] +then + echo "repo not specified on -r flag" + exit 1 +fi + +if [ -z "$issue_id" ] +then + echo "issue_id not specified on -i flag" + exit 1 +fi + +if ! echo "$issue_id" | grep -Eq '^POLICY-[0-9]*$' +then + echo "issue ID is invalid, it should be of form 'POLICY-nnnn'" + exit 1 +fi + +# shellcheck disable=SC2034 +# shellcheck disable=SC2046 +read -r repo \ + latest_released_tag \ + latest_snapshot_tag \ + changed_files \ + docker_images \ + <<< $(grep "$specified_repo" "$release_data_file" | tr ',' ' ' ) + +if [ ! "$repo" = "$specified_repo" ] +then + echo "repo '$specified_repo' not found in file 'pf_release_data.csv'" + exit 1 +fi + +next_release_version=${latest_snapshot_tag%-*} + +while true +do + read -r -p "have you run 'stage-release' on the '$repo' repo? " yes_no + case $yes_no in + [Yy]* ) break + ;; + + [Nn]* ) exit + ;; + + * ) echo "Please answer 'yes' or 'no'" + ;; + esac +done + +saved_current_dir=$(pwd) +cd "$repo_location/$repo" || exit 1 +if [ "$docker_images" != "" ] +then + mkart_flag="-d" +else + mkart_flag="" +fi + +if ! mkart.sh "$mkart_flag" +then + echo "generation of artifact release yaml file failed" + cd "$saved_current_dir" || exit 1 + exit 1 +fi + +cd "$saved_current_dir" || exit 1 + +echo "generating commit for $repo release: $latest_released_tag-->$next_release_version . . ." + +generateCommit.sh \ + -l "$repo_location" \ + -r "$repo" \ + -i "$issue_id" \ + -e "Release $repo: $next_release_version" \ + -m "This commit releases repo $repo." + +echo "commit for $repo release: $latest_released_tag-->$next_release_version generated" diff --git a/integration/src/main/scripts/release/releaseRepoImages.sh b/integration/src/main/scripts/release/releaseRepoImages.sh new file mode 100755 index 00000000..00eff051 --- /dev/null +++ b/integration/src/main/scripts/release/releaseRepoImages.sh @@ -0,0 +1,179 @@ +#!/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================================================== +# + +SCRIPT_NAME=$(basename "$0") +repo_location="./" +release_data_file="./pf_release_data.csv" + +usage() +{ + echo "" + echo "$SCRIPT_NAME - release the docker images for the specified repository by generating the release yaml file and" + echo " the release commit" + echo " usage: $SCRIPT_NAME [-options]" + echo "" + echo " options" + echo " -h - this help message" + echo " -d data_file - the policy release data file to use, defaults to '$release_data_file'" + echo " -l location - the location of the policy framework repos on the file system," + echo " defaults to '$repo_location'" + echo " -r repo - the policy repo to release" + echo " -i issue-id - issue ID in the format POLICY-nnnn" + echo "" + echo " examples:" + echo " $SCRIPT_NAME -l /home/user/onap -d /home/user/data/pf_release_data.csv -r policy/common -i POLICY-1234" + echo " release the 'policy/common' repo at location '/home/user/onap' using the release data" + echo " in the file '/home/user/data/pf_release_data.csv'" + exit 255; +} + +while getopts "hd:l:r:i:" opt +do + case $opt in + h) + usage + ;; + d) + release_data_file=$OPTARG + ;; + l) + repo_location=$OPTARG + ;; + r) + specified_repo=$OPTARG + ;; + i) + issue_id=$OPTARG + ;; + \?) + usage + exit 1 + ;; + esac +done + +if [ $OPTIND -eq 1 ] +then + echo "no arguments were specified" + usage +fi + +if [[ -z "$repo_location" ]] +then + echo "policy repo location not specified on -l flag" + exit 1 +fi + +if ! [ -d "$repo_location" ] +then + echo "policy repo location '$repo_location' not found" + exit 1 +fi + +if [[ -z "$release_data_file" ]] +then + echo "policy release data file not specified on -d flag" + exit 1 +fi + +if ! [ -f "$release_data_file" ] +then + echo "policy release data file '$release_data_file' not found" + exit 1 +fi + +if [ -z "$specified_repo" ] +then + echo "repo not specified on -r flag" + exit 1 +fi + +if [ -z "$issue_id" ] +then + echo "issue_id not specified on -i flag" + exit 1 +fi + +if ! echo "$issue_id" | grep -Eq '^POLICY-[0-9]*$' +then + echo "issue ID is invalid, it should be of form 'POLICY-nnnn'" + exit 1 +fi + +# shellcheck disable=SC2034 +read -r repo \ + latest_released_tag \ + latest_snapshot_tag \ + changed_files \ + docker_images \ + <<< "$(grep "$specified_repo" "$release_data_file" | tr ',' ' ' )" + +if [ ! "$repo" = "$specified_repo" ] +then + echo "repo '$specified_repo' not found in file 'pf_release_data.csv'" + exit 1 +fi + +next_release_version=${latest_snapshot_tag%-*} + +while true +do + read -r -p "have you run 'stage-release' on the '$repo' repo? " yes_no + case $yes_no in + [Yy]* ) break + ;; + + [Nn]* ) exit + ;; + + * ) echo "Please answer 'yes' or 'no'" + ;; + esac +done + +if [ "$docker_images" != "" ] +then + saved_current_dir=$(pwd) + cd "$repo_location/$repo" || exit 1 + # shellcheck disable=SC2046 + if ! mkdock.sh $(echo "$docker_images" | sed -e "s/'//g" -e "s/:/ /g") + then + echo "generation of docker image release container yaml file failed" + cd "$saved_current_dir" || exit 1 + exit 1 + fi + cd "$saved_current_dir" || exit 1 +else + echo "repo '$repo' does not have any docker images" + exit 1 +fi + +echo "generating commit for $repo docker image release: $latest_released_tag-->$next_release_version . . ." + +generateCommit.sh \ + -l "$repo_location" \ + -r "$repo" \ + -i "$issue_id" \ + -e "Release docker images for $repo: $next_release_version" \ + -m "This commit releases docker images for repo $repo." + +echo "commit for $repo docker image release: $latest_released_tag-->$next_release_version generated" diff --git a/integration/src/main/scripts/release/updateOomImages.sh b/integration/src/main/scripts/release/updateOomImages.sh new file mode 100755 index 00000000..ad337a8c --- /dev/null +++ b/integration/src/main/scripts/release/updateOomImages.sh @@ -0,0 +1,184 @@ +#!/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") +repo_location="./" +release_data_file="./pf_release_data.csv" + +# Use the bash internal OSTYPE variable to check for MacOS +if [[ "$OSTYPE" == "darwin"* ]] +then + SED="gsed" +else + SED="sed" +fi + +declare -a pf_repos=( + "policy/parent" + "policy/docker" + "policy/common" + "policy/models" + "policy/api" + "policy/pap" + "policy/drools-pdp" + "policy/apex-pdp" + "policy/xacml-pdp" + "policy/distribution" + "policy/gui" + "policy/clamp" + "policy/drools-applications" +) + +usage() +{ + echo "" + echo "$SCRIPT_NAME - generate an OOM commit to update the versions of Policy Framework images in values.yaml files" + echo "" + echo " usage: $SCRIPT_NAME [-options]" + echo "" + echo " options" + echo " -h - this help message" + echo " -d data_file - the policy release data file to use, defaults to '$release_data_file'" + echo " -l location - the location of the OOM repo on the file system," + echo " defaults to '$repo_location'" + echo " -i issue-id - issue ID in the format POLICY-nnnn" + echo "" + echo " examples:" + echo " $SCRIPT_NAME -l /home/user/onap -d /home/user/data/pf_release_data.csv -i POLICY-1234" + echo " update the version of policy framework images at location '/home/user/onap/oom' using the release data" + echo " in the file '/home/user/data/pf_release_data.csv'" + exit 255; +} + +while getopts "hd:l:i:" opt +do + case $opt in + h) + usage + ;; + d) + release_data_file=$OPTARG + ;; + l) + repo_location=$OPTARG + ;; + i) + issue_id=$OPTARG + ;; + \?) + usage + exit 1 + ;; + esac +done + +if [ $OPTIND -eq 1 ] +then + echo "no arguments were specified" + usage +fi + +if [[ -z "$repo_location" ]] +then + echo "OOM repo location not specified on -l flag" + exit 1 +fi + +if ! [ -d "$repo_location" ] +then + echo "OOM repo location '$repo_location' not found" + exit 1 +fi + +if [[ -z "$release_data_file" ]] +then + echo "policy release data file not specified on -d flag" + exit 1 +fi + +if ! [ -f "$release_data_file" ] +then + echo "policy release data file '$release_data_file' not found" + exit 1 +fi + +if [ -z "$issue_id" ] +then + echo "issue_id not specified on -i flag" + exit 1 +fi + +if ! echo "$issue_id" | grep -Eq '^POLICY-[0-9]*$' +then + echo "issue ID is invalid, it should be of form 'POLICY-nnnn'" + exit 1 +fi + +for specified_repo in "${pf_repos[@]}" +do + # shellcheck disable=SC2034 + # shellcheck disable=SC2046 + read -r repo \ + latest_released_tag \ + latest_snapshot_tag \ + changed_files docker_images \ + <<< $(grep "$specified_repo" "$release_data_file" | tr ',' ' ' ) + + if [ ! "$repo" = "$specified_repo" ] + then + echo "repo '$specified_repo' not found in file 'pf_release_data.csv'" + continue + fi + + if [ "$docker_images" = "" ] + then + continue + fi + + for docker_image in $(echo "$docker_images" | tr ':' ' ') + do + new_image="$docker_image:$latest_released_tag" + + echo "updating OOM image $new_image . . ." + find "$repo_location/oom/kubernetes/policy/components" \ + -name values.yaml \ + -exec \ + $SED -i \ + "s/^image:[ |\t]*onap\/$docker_image:[0-9]*\.[0-9]*\.[0-9]*$/image: onap\/$new_image/" {} \; + echo "OOM image $docker_image:$latest_released_tag updated" + done +done + + +echo "generating OOM commit to update policy framework docker image versions . . ." + +generateCommit.sh \ + -l "$repo_location" \ + -r oom \ + -i "$issue_id" \ + -e "[POLICY] Update docker images to latest versions" \ + -m "The image versions in policy values.yaml files have been updated" + +echo "OOM commit to update policy framework docker image versions generated" + 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" diff --git a/integration/src/main/scripts/release/updateRefs.sh b/integration/src/main/scripts/release/updateRefs.sh new file mode 100755 index 00000000..0f253f97 --- /dev/null +++ b/integration/src/main/scripts/release/updateRefs.sh @@ -0,0 +1,413 @@ +#!/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") +repo_location="./" +release_data_file="./pf_release_data.csv" + +# 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 - updates the inter-repo references in Policy Framework POM files" + echo "" + echo " usage: $SCRIPT_NAME [-options]" + echo "" + echo " options" + echo " -h - this help message" + echo " -d data_file - the policy release data file to use, generated by the 'getReleaseData.sh' script," + echo " defaults to '$release_data_file'" + echo " -l location - the location of the policy framework repos on the file system," + echo " defaults to '$repo_location'" + echo " -r repo - the policy repo to update" + echo " -p - update policy/parent references" + echo " -c - update policy/common references" + echo " -m - update policy/model references" + echo " -o - update policy/drools-pdp references" + echo " -x - update policy/apex-pdp references" + echo " -k - update docker base images in Dockerfiles" + echo " -s - update release references to snapshot references," + echo " if omitted, snapshot references are updated to release references" + echo "" + echo " examples:" + echo " $SCRIPT_NAME -pcm -r policy/pap" + echo " update the parent, common, and models references of policy/pap" + echo " to the current released version" + echo "" + echo " $SCRIPT_NAME -c -m -s -r policy/api" + echo " update the common and models references of policy/api" + echo " to the current snapshot version" + exit 255; +} + +update_parent=false +update_common=false +update_models=false +update_drools_pdp=false +update_apex_pdp=false +update_snapshot=false +update_docker=false + +while getopts "hd:l:r:pcmoxks" opt +do + case $opt in + h) + usage + ;; + d) + release_data_file=$OPTARG + ;; + l) + repo_location=$OPTARG + ;; + r) + specified_repo=$OPTARG + ;; + p) + update_parent=true + ;; + c) + update_common=true + ;; + m) + update_models=true + ;; + o) + update_drools_pdp=true + ;; + x) + update_apex_pdp=true + ;; + k) + update_docker=true + ;; + s) + update_snapshot=true + ;; + \?) + usage + exit 1 + ;; + esac +done + +if [ $OPTIND -eq 1 ] +then + echo "no arguments were specified" + usage +fi + +if [[ -z "$repo_location" ]] +then + echo "policy repo location not specified on -l flag" + exit 1 +fi + +if ! [ -d "$repo_location" ] +then + echo "policy repo location '$repo_location' not found" + exit 1 +fi + +if [[ -z "$release_data_file" ]] +then + echo "policy release data file not specified on -d flag" + exit 1 +fi + +if ! [ -f "$release_data_file" ] +then + echo "policy release data file '$release_data_file' not found" + exit 1 +fi + +if [ -z "$specified_repo" ] +then + echo "repo not specified on -r flag" + exit 1 +fi + +# shellcheck disable=SC2034 +# shellcheck disable=SC2046 +read -r parent_repo \ + parent_latest_released_tag \ + parent_latest_snapshot_tag \ + parent_changed_files \ + parent_docker_images \ + <<< $(grep policy/parent "$release_data_file" | tr ',' ' ' ) + +# shellcheck disable=SC2034 +# shellcheck disable=SC2046 +read -r common_repo \ + common_latest_released_tag \ + common_latest_snapshot_tag \ + common_changed_files \ + common_docker_images \ + <<< $(grep policy/common "$release_data_file" | tr ',' ' ' ) + +# shellcheck disable=SC2034 +# shellcheck disable=SC2046 +read -r docker_repo \ + docker_latest_released_tag \ + docker_latest_snapshot_tag \ + docker_changed_files \ + docker_docker_images \ + <<< $(grep policy/docker "$release_data_file" | tr ',' ' ' ) + +# shellcheck disable=SC2034 +# shellcheck disable=SC2046 +read -r models_repo \ + models_latest_released_tag \ + models_latest_snapshot_tag \ + models_changed_files \ + models_docker_images \ + <<< $(grep policy/models "$release_data_file" | tr ',' ' ' ) + +# shellcheck disable=SC2034 +# shellcheck disable=SC2046 +read -r drools_pdp_repo \ + drools_pdp_latest_released_tag \ + drools_pdp_latest_snapshot_tag \ + drools_pdp_changed_files \ + drools_pdp_docker_images \ + <<< $(grep policy/drools-pdp "$release_data_file" | tr ',' ' ' ) + +# shellcheck disable=SC2034 +# shellcheck disable=SC2046 +read -r apex_pdp_repo \ + apex_pdp_latest_released_tag \ + apex_pdp_latest_snapshot_tag \ + apex_pdp_changed_files \ + apex_pdp_docker_images \ + <<< $(grep policy/apex-pdp "$release_data_file" | tr ',' ' ' ) + +# shellcheck disable=SC2034 +# shellcheck disable=SC2046 +read -r target_repo \ + target_latest_released_tag \ + target_latest_snapshot_tag \ + target_changed_files \ + target_docker_images \ + <<< $(grep "$specified_repo" "$release_data_file" | tr ',' ' ' ) + +if [ -z "$target_repo" ] +then + echo "specified repo '$specified_repo' not found in policy release data file '$release_data_file'" + exit 1 +fi + +if [ ! "$specified_repo" = "$target_repo" ] +then + echo "specified repo '$specified_repo' does not match target repo '$target_repo'" + exit 1 +fi + +if [ "$update_parent" = true ] +then + if [ "$specified_repo" = "policy/parent" ] + then + if [ "$update_snapshot" = true ] + then + major_version=$(echo "$parent_latest_released_tag" | $SED -E 's/^([0-9]*)\.[0-9]*\.[0-9]*$/\1/') + minor_version=$(echo "$parent_latest_released_tag" | $SED -E 's/^[0-9]*\.([0-9]*)\.[0-9]*$/\1/') + patch_version=$(echo "$parent_latest_released_tag" | $SED -E 's/^[0-9]*\.[0-9]*\.([0-9]*)$/\1/') + new_patch_version=$(("$patch_version"+1)) + + new_snapshot_tag="$major_version"."$minor_version"."$new_patch_version"-SNAPSHOT + + echo updating policy parent reference to "$new_snapshot_tag" on "$repo_location/$target_repo" . . . + $SED -i \ + "s/<version.parent.resources>.*<\/version.parent.resources>/<version.parent.resources>$new_snapshot_tag<\/version.parent.resources>/" \ + "$repo_location/policy/parent/integration/pom.xml" + result_code=$? + else + next_release_version=${parent_latest_snapshot_tag%-*} + + echo "updating policy parent reference to $next_release_version on $repo_location/$target_repo . . ." + $SED -i \ + "s/<version.parent.resources>.*<\/version.parent.resources>/<version.parent.resources>$next_release_version<\/version.parent.resources>/" \ + "$repo_location/policy/parent/integration/pom.xml" + result_code=$? + fi + else + if [ "$update_snapshot" = true ] + then + echo "updating policy parent reference to $parent_latest_snapshot_tag on $repo_location/$target_repo . . ." + updateParentRef.sh \ + -f "$repo_location/$target_repo/pom.xml" \ + -g org.onap.policy.parent \ + -a integration \ + -v "$parent_latest_snapshot_tag" + result_code=$? + else + echo "updating policy parent reference to $parent_latest_released_tag on $repo_location/$target_repo . . ." + updateParentRef.sh \ + -f "$repo_location/$target_repo/pom.xml" \ + -g org.onap.policy.parent \ + -a integration \ + -v "$parent_latest_released_tag" + result_code=$? + fi + fi + if [[ "$result_code" -eq 0 ]] + then + echo "policy parent reference updated on $repo_location/$target_repo" + else + echo "policy parent reference update failed on $repo_location/$target_repo" + exit 1 + fi +fi + +if [ "$update_common" = true ] +then + if [ "$update_snapshot" = true ] + then + echo "updating policy common reference to $common_latest_snapshot_tag on $repo_location/$target_repo . . ." + $SED -i \ + -e "s/<policy.common.version>.*<\/policy.common.version>/<policy.common.version>$common_latest_snapshot_tag<\/policy.common.version>/" \ + -e "s/<version.policy.common>.*<\/version.policy.common>/<version.policy.common>$common_latest_snapshot_tag<\/version.policy.common>/" \ + "$repo_location/$target_repo/pom.xml" + result_code=$? + else + echo "updating policy common reference to $common_latest_released_tag on $repo_location/$target_repo . . ." + $SED -i \ + -e "s/<policy.common.version>.*<\/policy.common.version>/<policy.common.version>$common_latest_released_tag<\/policy.common.version>/" \ + -e "s/<version.policy.common>.*<\/version.policy.common>/<version.policy.common>$common_latest_released_tag<\/version.policy.common>/" \ + "$repo_location/$target_repo/pom.xml" + result_code=$? + fi + if [[ "$result_code" -eq 0 ]] + then + echo "policy common reference updated on $repo_location/$target_repo" + else + echo "policy common reference update failed on $repo_location/$target_repo" + exit 1 + fi +fi + +if [ "$update_models" = true ] +then + if [ "$update_snapshot" = true ] + then + echo "updating policy models reference to $models_latest_snapshot_tag on $repo_location/$target_repo . . ." + $SED -i \ + -e "s/<policy.models.version>.*<\/policy.models.version>/<policy.models.version>$models_latest_snapshot_tag<\/policy.models.version>/" \ + -e "s/<version.policy.models>.*<\/version.policy.models>/<version.policy.models>$models_latest_snapshot_tag<\/version.policy.models>/" \ + "$repo_location/$target_repo/pom.xml" + result_code=$? + else + echo "updating policy models reference to $models_latest_released_tag on $repo_location/$target_repo . . ." + $SED -i \ + -e "s/<policy.models.version>.*<\/policy.models.version>/<policy.models.version>$models_latest_released_tag<\/policy.models.version>/" \ + -e "s/<version.policy.models>.*<\/version.policy.models>/<version.policy.models>$models_latest_released_tag<\/version.policy.models>/" \ + "$repo_location/$target_repo/pom.xml" + result_code=$? + fi + if [[ "$result_code" -eq 0 ]] + then + echo "policy models reference updated on $repo_location/$target_repo" + else + echo "policy models reference update failed on $repo_location/$target_repo" + exit 1 + fi +fi + +if [ "$update_drools_pdp" = true ] +then + if [ "$update_snapshot" = true ] + then + echo "updating policy drools-pdp reference to $drools_pdp_latest_snapshot_tag on $repo_location/$target_repo . . ." + $SED -i \ + -e "s/<policy.drools-pdp.version>.*<\/policy.drools-pdp.version>/<policy.drools-pdp.version>$drools_pdp_latest_snapshot_tag<\/policy.drools-pdp.version>/" \ + -e "s/<version.policy.drools-pdp>.*<\/version.policy.drools-pdp>/<version.policy.drools-pdp>$drools_pdp_latest_snapshot_tag<\/version.policy.drools-pdp>/" \ + "$repo_location/$target_repo/pom.xml" + result_code=$? + else + echo "updating policy drools-pdp reference to $drools_pdp_latest_released_tag on $repo_location/$target_repo . . ." + $SED -i \ + -e "s/<policy.drools-pdp.version>.*<\/policy.drools-pdp.version>/<policy.drools-pdp.version>$drools_pdp_latest_released_tag<\/policy.drools-pdp.version>/" \ + -e "s/<version.policy.drools-pdp>.*<\/version.policy.drools-pdp>/<version.policy.drools-pdp>$drools_pdp_latest_released_tag<\/version.policy.drools-pdp>/" \ + "$repo_location/$target_repo/pom.xml" + result_code=$? + fi + if [[ "$result_code" -eq 0 ]] + then + echo "policy drools-pdp reference updated on $repo_location/$target_repo" + else + echo "policy drools-pdp reference update failed on $repo_location/$target_repo" + exit 1 + fi +fi + +if [ "$update_apex_pdp" = true ] +then + if [ "$update_snapshot" = true ] + then + echo "updating policy apex-pdp reference to $apex_pdp_latest_snapshot_tag on $repo_location/$target_repo . . ." + $SED -i \ + -e "s/<policy.apex-pdp.version>.*<\/policy.apex-pdp.version>/<policy.apex-pdp.version>$apex_pdp_latest_snapshot_tag<\/policy.apex-pdp.version>/" \ + -e "s/<version.policy.apex-pdp>.*<\/version.policy.apex-pdp>/<version.policy.apex-pdp>$apex_pdp_latest_snapshot_tag<\/version.policy.apex-pdp>/" \ + "$repo_location/$target_repo/pom.xml" + result_code=$? + else + echo "updating policy apex-pdp reference to $apex_pdp_latest_released_tag on $repo_location/$target_repo . . ." + $SED -i \ + -e "s/<policy.apex-pdp.version>.*<\/policy.apex-pdp.version>/<policy.apex-pdp.version>$apex_pdp_latest_released_tag<\/policy.apex-pdp.version>/" \ + -e "s/<version.policy.apex-pdp>.*<\/version.policy.apex-pdp>/<version.policy.apex-pdp>$apex_pdp_latest_released_tag<\/version.policy.apex-pdp>/" \ + "$repo_location/$target_repo/pom.xml" + result_code=$? + fi + if [[ "$result_code" -eq 0 ]] + then + echo "policy apex-pdp reference updated on $repo_location/$target_repo" + else + echo "policy apex-pdp reference update failed on $repo_location/$target_repo" + exit 1 + fi +fi + +if [ "$update_docker" = true ] && [ "$target_docker_images" != "" ] +then + echo "updating docker base images to version $docker_latest_released_tag on repo $repo_location/$target_repo . . ." + find "$repo_location/$target_repo" \ + -name '*Docker*' + find "$repo_location/$target_repo" \ + -name '*Docker*' \ + -exec $SED -r -i "s/^(FROM onap\/policy-j[d|r][k|e]-alpine:)[0-9]*.[0-9]*.[0-9]*$/\1$docker_latest_released_tag/" {} \; + result_code=$? + if [[ "$result_code" -eq 0 ]] + then + echo "docker base images updated on $repo_location/$target_repo" + else + echo "docker base images update failed on $repo_location/$target_repo" + exit 1 + fi +fi diff --git a/integration/src/main/scripts/reports/pf_status_report.sh b/integration/src/main/scripts/reports/pf_status_report.sh new file mode 100755 index 00000000..c979066c --- /dev/null +++ b/integration/src/main/scripts/reports/pf_status_report.sh @@ -0,0 +1,120 @@ +#!/bin/bash + +# ============LICENSE_START================================================ +# ONAP +# ========================================================================= +# Copyright (C) 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================================================== +# + +function health_check() { + health_dir="$1" + + health_report_temp_file=$(mktemp) + + report_month=$( \ + curl -s "https://logs.onap.org/onap-integration/daily/$health_dir"/ | \ + grep href | \ + sort | \ + tail -1 | \ + sed -e 's/^.*href="//' \ + -e 's/\/".*$//' + ) + + report_last_health=$( \ + curl -s "https://logs.onap.org/onap-integration/daily/$health_dir/$report_month/" | \ + grep href | \ + sort | \ + tail -1 | \ + sed -e 's/^.*href="//' \ + -e 's/\/".*$//' + ) + + curl -s --output "$health_report_temp_file" \ + "https://logs.onap.org/onap-integration/daily/$health_dir/$report_month/$report_last_health/xtesting-healthcheck/full/full/report.html" + health_check_result=$( + gunzip -c "$health_report_temp_file" | \ + grep 'window.output\["stats"\]' | \ + sed 's/},{/}\n{/g' | \ + grep health-policy | \ + sed -e 's/{//g' \ + -e 's/}//g' \ + -e 's/"//g' \ + -e 's/label://' | \ + awk -F',' '{printf("%s,%s,%s\n", $3,$4,$2)}' + ) + + report_day="${report_last_health%%_*}" + report_hour_minute="${report_last_health#*_}" + report_hour_minute="${report_hour_minute/-/:}" + echo "$health_dir,$report_month-$report_day $report_hour_minute,$health_check_result" +} + +echo "" +echo "health checks" +echo "-------------" + +health_check onap-daily-dt-oom-master +health_check onap-daily-dt-oom-jakarta +health_check onap-daily-dt-oom-istanbul +health_check onap_daily_pod4_master + +jenkins_report_temp_file=$(mktemp) + +curl -s https://jenkins.onap.org/view/policy/ | \ + sed -e 's/<tr id=/\n<tr id=/g' \ + -e 's/><td data=/\n><td data=/g' | \ + grep 'tr id=' | \ + sed -e 's/"//g' \ + -e 's/<tr id=//' \ + -e 's/class= //' > "$jenkins_report_temp_file" + +echo "" +echo "failing jobs" +echo "------------" + +grep "job-status-red" "$jenkins_report_temp_file" | \ + grep -v stage | + cut -f1 -d' ' + +echo "" +echo "warning jobs" +echo "------------" + +grep "job-status-yellow" "$jenkins_report_temp_file" | \ + grep -v clm | + cut -f1 -d' ' + +echo "" +echo "invalid jobs" +echo "------------" +grep -v -E "(blue|red|yellow|verify|merge)" "$jenkins_report_temp_file" | \ + cut -f1 -d' ' + +echo "" +echo "bugs" +echo "----" +curl -s https://jira.onap.org/issues/?jql=PROJECT%20%3D%20POLICY%20AND%20issuetype%20%3D%20Bug%20AND%20status%20!%3D%20Closed%20ORDER%20BY%20key%20ASC \ | + grep 'data-issue-table-model-state' | \ + sed -e 's/"/\"/g' \ + -e 's/.*";jiraHasIssues";:true,";page";:[0-9]*,";pageSize";:[0-9]*,";startIndex";:[0-9]*,";table";:\[//' \ + -e 's/,";title";:";";,";total";:[0-9]*,";url";:";";,";sortBy";:\].*$//' \ + -e 's/}}/}}\n/g' | \ + grep 'POLICY-' | \ + sed -e 's/^.*key=/key=/g' \ + -e 's/";:";/=/g' \ + -e 's/";,";/,/g' \ + -e 's/^.*key=/key=/g' \ + -e 's/";:{";description=.*$//' |