Code Review
/
releng
/
global-jjb.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Fix shellcheck errors in scripts
[releng/global-jjb.git]
/
shell
/
release-job.sh
diff --git
a/shell/release-job.sh
b/shell/release-job.sh
index
ccaa782
..
3ad4530
100644
(file)
--- a/
shell/release-job.sh
+++ b/
shell/release-job.sh
@@
-14,9
+14,12
@@
set -eu -o pipefail
echo "INFO: creating virtual environment"
virtualenv -p python3 /tmp/venv
PATH=/tmp/venv/bin:$PATH
echo "INFO: creating virtual environment"
virtualenv -p python3 /tmp/venv
PATH=/tmp/venv/bin:$PATH
-pipup="python -m pip install -q --upgrade pip
lftools jsonschema niet
twine yq"
+pipup="python -m pip install -q --upgrade pip
idna==2.8 lftools jsonschema
twine yq"
echo "INFO: $pipup"
$pipup
echo "INFO: $pipup"
$pipup
+# show installed versions
+python -m pip --version
+python -m pip freeze
#Functions.
#Functions.
@@
-29,10
+32,12
@@
set_variables_common(){
NEXUS_PATH="${SILO}/${JENKINS_HOSTNAME}/"
# Verify if using release file or parameters
if $USE_RELEASE_FILE ; then
NEXUS_PATH="${SILO}/${JENKINS_HOSTNAME}/"
# Verify if using release file or parameters
if $USE_RELEASE_FILE ; then
- release_files=$(git diff-tree -m --no-commit-id -r "$GIT_COMMIT" --name-only -- "releases/" ".releases/")
+ release_files=$(git diff-tree -m --no-commit-id -r "$GIT_COMMIT" "$GIT_COMMIT^1" \
+ --name-only -- "releases/" ".releases/")
if (( $(grep -c . <<<"$release_files") > 1 )); then
echo "INFO: RELEASE FILES ARE AS FOLLOWS: $release_files"
if (( $(grep -c . <<<"$release_files") > 1 )); then
echo "INFO: RELEASE FILES ARE AS FOLLOWS: $release_files"
- echo "ERROR: Committing multiple release files in the same commit OR rename/amend of existing files is not supported."
+ echo "ERROR: Adding multiple release files in the same commit"
+ echo "ERROR: OR rename/amend/delete of existing files is not supported."
exit 1
else
release_file="$release_files"
exit 1
else
release_file="$release_files"
@@
-44,13
+49,27
@@
set_variables_common(){
fi
# Jenkins parameter drop-down defaults DISTRIBUTION_TYPE to None
fi
# Jenkins parameter drop-down defaults DISTRIBUTION_TYPE to None
+ # in the contain/maven release job; get value from release yaml.
+ # Packagecloud and PyPI jobs set the appropriate value.
DISTRIBUTION_TYPE="${DISTRIBUTION_TYPE:-None}"
if [[ $DISTRIBUTION_TYPE == "None" ]]; then
DISTRIBUTION_TYPE="${DISTRIBUTION_TYPE:-None}"
if [[ $DISTRIBUTION_TYPE == "None" ]]; then
- DISTRIBUTION_TYPE=$(niet ".distribution_type" "$release_file")
+ if ! DISTRIBUTION_TYPE=$(yq -r ".distribution_type" "$release_file"); then
+ echo "ERROR: Failed to get distribution_type from $release_file"
+ exit 1
+ fi
fi
PATCH_DIR=$(mktemp -d)
fi
PATCH_DIR=$(mktemp -d)
+ TAG_RELEASE="${TAG_RELEASE:-None}"
+ if [[ $TAG_RELEASE == "None" ]]; then
+ if grep -q "tag_release" $release_file ; then
+ TAG_RELEASE=$(yq -r .tag_release "$release_file")
+ else
+ TAG_RELEASE=true
+ fi
+ fi
+
# Displaying Release Information (Common variables)
printf "\t%-30s\n" RELEASE_ENVIRONMENT_INFO:
printf "\t%-30s %s\n" RELEASE_FILE: "$release_file"
# Displaying Release Information (Common variables)
printf "\t%-30s\n" RELEASE_ENVIRONMENT_INFO:
printf "\t%-30s %s\n" RELEASE_FILE: "$release_file"
@@
-60,23
+79,24
@@
set_variables_common(){
printf "\t%-30s %s\n" SILO: "$SILO"
printf "\t%-30s %s\n" PROJECT: "$PROJECT"
printf "\t%-30s %s\n" PROJECT-DASHED: "${PROJECT//\//-}"
printf "\t%-30s %s\n" SILO: "$SILO"
printf "\t%-30s %s\n" PROJECT: "$PROJECT"
printf "\t%-30s %s\n" PROJECT-DASHED: "${PROJECT//\//-}"
+ printf "\t%-30s %s\n" TAG_RELEASE: "$TAG_RELEASE"
printf "\t%-30s %s\n" DISTRIBUTION_TYPE: "$DISTRIBUTION_TYPE"
}
set_variables_maven(){
echo "INFO: Setting maven variables"
if [[ -z ${VERSION:-} ]]; then
printf "\t%-30s %s\n" DISTRIBUTION_TYPE: "$DISTRIBUTION_TYPE"
}
set_variables_maven(){
echo "INFO: Setting maven variables"
if [[ -z ${VERSION:-} ]]; then
- VERSION=$(
niet
".version" "$release_file")
+ VERSION=$(
yq -r
".version" "$release_file")
fi
if [[ -z ${GIT_TAG:-} ]]; then
if grep -q "git_tag" "$release_file" ; then
fi
if [[ -z ${GIT_TAG:-} ]]; then
if grep -q "git_tag" "$release_file" ; then
- GIT_TAG=$(
niet
".git_tag" "$release_file")
+ GIT_TAG=$(
yq -r
".git_tag" "$release_file")
else
GIT_TAG="$VERSION"
fi
fi
if [[ -z ${LOG_DIR:-} ]]; then
else
GIT_TAG="$VERSION"
fi
fi
if [[ -z ${LOG_DIR:-} ]]; then
- LOG_DIR=$(
niet
".log_dir" "$release_file")
+ LOG_DIR=$(
yq -r
".log_dir" "$release_file")
fi
LOGS_URL="${LOGS_SERVER}/${NEXUS_PATH}${LOG_DIR}"
LOGS_URL=${LOGS_URL%/} # strip any trailing '/'
fi
LOGS_URL="${LOGS_SERVER}/${NEXUS_PATH}${LOG_DIR}"
LOGS_URL=${LOGS_URL%/} # strip any trailing '/'
@@
-92,27
+112,27
@@
set_variables_maven(){
set_variables_container(){
echo "INFO: Setting container variables"
if [[ -z ${VERSION:-} ]]; then
set_variables_container(){
echo "INFO: Setting container variables"
if [[ -z ${VERSION:-} ]]; then
- VERSION=$(
niet
".container_release_tag" "$release_file")
+ VERSION=$(
yq -r
".container_release_tag" "$release_file")
fi
if [[ -z ${GIT_TAG:-} ]]; then
if grep -q "git_tag" "$release_file" ; then
fi
if [[ -z ${GIT_TAG:-} ]]; then
if grep -q "git_tag" "$release_file" ; then
- GIT_TAG=$(
niet
".git_tag" "$release_file")
+ GIT_TAG=$(
yq -r
".git_tag" "$release_file")
else
GIT_TAG="$VERSION"
fi
fi
if grep -q "container_pull_registry" "$release_file" ; then
else
GIT_TAG="$VERSION"
fi
fi
if grep -q "container_pull_registry" "$release_file" ; then
- CONTAINER_PULL_REGISTRY=$(
niet
".container_pull_registry" "$release_file")
+ CONTAINER_PULL_REGISTRY=$(
yq -r
".container_pull_registry" "$release_file")
fi
if grep -q "container_push_registry" "$release_file" ; then
fi
if grep -q "container_push_registry" "$release_file" ; then
- CONTAINER_PUSH_REGISTRY=$(
niet
".container_push_registry" "$release_file")
+ CONTAINER_PUSH_REGISTRY=$(
yq -r
".container_push_registry" "$release_file")
fi
# Make sure both pull and push registries are defined
if [ -z ${CONTAINER_PULL_REGISTRY+x} ] || [ -z ${CONTAINER_PUSH_REGISTRY+x} ]; then
echo "ERROR: CONTAINER_PULL_REGISTRY and CONTAINER_PUSH_REGISTRY need to be defined"
exit 1
fi
fi
# Make sure both pull and push registries are defined
if [ -z ${CONTAINER_PULL_REGISTRY+x} ] || [ -z ${CONTAINER_PUSH_REGISTRY+x} ]; then
echo "ERROR: CONTAINER_PULL_REGISTRY and CONTAINER_PUSH_REGISTRY need to be defined"
exit 1
fi
- ref=$(
niet
".ref" "$release_file")
+ ref=$(
yq -r
".ref" "$release_file")
# Continuing displaying Release Information (Container)
printf "\t%-30s\n" RELEASE_CONTAINER_INFO:
# Continuing displaying Release Information (Container)
printf "\t%-30s\n" RELEASE_CONTAINER_INFO:
@@
-126,22
+146,22
@@
set_variables_container(){
set_variables_pypi(){
echo "INFO: Setting pypi variables"
if [[ -z ${LOG_DIR:-} ]]; then
set_variables_pypi(){
echo "INFO: Setting pypi variables"
if [[ -z ${LOG_DIR:-} ]]; then
- LOG_DIR=$(
niet
".log_dir" "$release_file")
+ LOG_DIR=$(
yq -r
".log_dir" "$release_file")
fi
LOGS_URL="${LOGS_SERVER}/${NEXUS_PATH}${LOG_DIR}"
LOGS_URL=${LOGS_URL%/} # strip any trailing '/'
if [[ -z ${PYPI_PROJECT:-} ]]; then
fi
LOGS_URL="${LOGS_SERVER}/${NEXUS_PATH}${LOG_DIR}"
LOGS_URL=${LOGS_URL%/} # strip any trailing '/'
if [[ -z ${PYPI_PROJECT:-} ]]; then
- PYPI_PROJECT=$(
niet
".pypi_project" "$release_file")
+ PYPI_PROJECT=$(
yq -r
".pypi_project" "$release_file")
fi
if [[ -z ${PYTHON_VERSION:-} ]]; then
fi
if [[ -z ${PYTHON_VERSION:-} ]]; then
- PYTHON_VERSION=$(
niet
".python_version" "$release_file")
+ PYTHON_VERSION=$(
yq -r
".python_version" "$release_file")
fi
if [[ -z ${VERSION:-} ]]; then
fi
if [[ -z ${VERSION:-} ]]; then
- VERSION=$(
niet
".version" "$release_file")
+ VERSION=$(
yq -r
".version" "$release_file")
fi
if [[ -z ${GIT_TAG:-} ]]; then
if grep -q "git_tag" "$release_file" ; then
fi
if [[ -z ${GIT_TAG:-} ]]; then
if grep -q "git_tag" "$release_file" ; then
- GIT_TAG=$(
niet
".git_tag" "$release_file")
+ GIT_TAG=$(
yq -r
".git_tag" "$release_file")
else
GIT_TAG="$VERSION"
fi
else
GIT_TAG="$VERSION"
fi
@@
-161,23
+181,23
@@
set_variables_pypi(){
set_variables_packagecloud(){
echo "INFO: Setting packagecloud variables"
if [[ -z ${VERSION:-} ]]; then
set_variables_packagecloud(){
echo "INFO: Setting packagecloud variables"
if [[ -z ${VERSION:-} ]]; then
- VERSION=$(
niet
".version" "$release_file")
+ VERSION=$(
yq -r
".version" "$release_file")
fi
if [[ -z ${GIT_TAG:-} ]]; then
if grep -q "git_tag" $release_file ; then
fi
if [[ -z ${GIT_TAG:-} ]]; then
if grep -q "git_tag" $release_file ; then
- GIT_TAG=$(
niet
".git_tag" "$release_file")
+ GIT_TAG=$(
yq -r
".git_tag" "$release_file")
else
GIT_TAG="$VERSION"
fi
fi
if [[ -z ${LOG_DIR:-} ]]; then
else
GIT_TAG="$VERSION"
fi
fi
if [[ -z ${LOG_DIR:-} ]]; then
- LOG_DIR=$(
niet
".log_dir" "$release_file")
+ LOG_DIR=$(
yq -r
".log_dir" "$release_file")
fi
if [[ -z ${REF:-} ]]; then
fi
if [[ -z ${REF:-} ]]; then
- REF=$(
niet
".ref" "$release_file")
+ REF=$(
yq -r
".ref" "$release_file")
fi
if [[ -z ${PACKAGE_NAME:-} ]]; then
fi
if [[ -z ${PACKAGE_NAME:-} ]]; then
- PACKAGE_NAME=$(
niet
".package_name" "$release_file")
+ PACKAGE_NAME=$(
yq -r
".package_name" "$release_file")
fi
logs_url="${LOGS_SERVER}/${NEXUS_PATH}${LOG_DIR}"
logs_url=${logs_url%/} # strip any trailing '/'
fi
logs_url="${LOGS_SERVER}/${NEXUS_PATH}${LOG_DIR}"
logs_url=${logs_url%/} # strip any trailing '/'
@@
-198,7
+218,7
@@
verify_schema(){
verify_version(){
# Verify allowed patterns "#.#.#" (SemVer) or "v#.#.#"
echo "INFO: Verifying version $VERSION"
verify_version(){
# Verify allowed patterns "#.#.#" (SemVer) or "v#.#.#"
echo "INFO: Verifying version $VERSION"
- allowed_version_regex="^
((v?)([0-9]+)\.([0-9]+)\.([0-9]+))
$"
+ allowed_version_regex="^
[vV]?(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(\-(0|[1-9][0-9]*|[0-9]*[A-Za-z-][0-9A-Za-z-]*)(\.(0|[1-9][0-9]*|[0-9]*[A-Za-z-][0-9A-Za-z-]*))*)?(\+[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?
$"
if [[ $VERSION =~ $allowed_version_regex ]]; then
echo "INFO: The version $VERSION is valid"
else
if [[ $VERSION =~ $allowed_version_regex ]]; then
echo "INFO: The version $VERSION is valid"
else
@@
-251,6
+271,11
@@
verify_packagecloud_match_release(){
# sigul is only available on Centos
# TODO: write tag-github-repo function
tag-gerrit-repo(){
# sigul is only available on Centos
# TODO: write tag-github-repo function
tag-gerrit-repo(){
+ if [[ $TAG_RELEASE == false ]]; then
+ echo "INFO: Skipping gerrit repo tag"
+ return
+ fi
+
echo "INFO: tag gerrit with $GIT_TAG"
# Import public signing key
gpg --import "$SIGNING_PUBKEY"
echo "INFO: tag gerrit with $GIT_TAG"
# Import public signing key
gpg --import "$SIGNING_PUBKEY"
@@
-310,11
+335,12
@@
nexus_release(){
container_release_file(){
echo "INFO: Processing container release"
container_release_file(){
echo "INFO: Processing container release"
+ docker --version
local lfn_umbrella
lfn_umbrella="$(echo "$GERRIT_URL" | awk -F"." '{print $2}')"
local lfn_umbrella
lfn_umbrella="$(echo "$GERRIT_URL" | awk -F"." '{print $2}')"
- for namequoted in $(
cat $release_file | yq '.containers[].name'
); do
- versionquoted=$(
cat $release_file | yq ".containers[] |select(.name==$namequoted) |.version"
)
+ for namequoted in $(
yq '.containers[].name' $release_file
); do
+ versionquoted=$(
yq ".containers[] |select(.name==$namequoted) |.version" $release_file
)
#Remove extra yaml quotes
name="${namequoted#\"}"
#Remove extra yaml quotes
name="${namequoted#\"}"