From 0bc15604215d26ec63250915aaf7027496ea115b Mon Sep 17 00:00:00 2001 From: Vladimir Khlyunev Date: Wed, 13 Feb 2019 12:17:54 +0400 Subject: [PATCH] Cleanup shell scripts - Remove unused variables - Invert -z logic Change-Id: Ie0b53279f641bcc1a108b2d3dfd255737879f939 --- maintenance-ci/common/scripts/delete_heat_stack.sh | 4 ++-- maintenance-ci/common/scripts/deploy_heat_stack.sh | 6 +++--- maintenance-ci/common/scripts/update-jenkins-jobs.sh | 11 ++++------- maintenance-ci/common/scripts/update-jenkins-views.sh | 8 +------- 4 files changed, 10 insertions(+), 19 deletions(-) diff --git a/maintenance-ci/common/scripts/delete_heat_stack.sh b/maintenance-ci/common/scripts/delete_heat_stack.sh index c60b384..0c44074 100755 --- a/maintenance-ci/common/scripts/delete_heat_stack.sh +++ b/maintenance-ci/common/scripts/delete_heat_stack.sh @@ -12,9 +12,9 @@ fi source "${OPENSTACK_CLIENTS_VENV}"/bin/activate source "${OPENRC_FILE?}" - if [ -z "${STACK_NAME}" ] ; then + if [ ! -z "${STACK_NAME}" ] ; then openstack stack delete -y "${STACK_NAME}" - elif [ -z "${STACK_PREFIX}" ] ; then + elif [ ! -z "${STACK_PREFIX}" ] ; then for stack in $(openstack stack list -c 'Stack Name' -f value) ; do if [[ ${stack} == ${STACK_PREFIX}* ]] ; then openstack stack delete -y "${stack}" diff --git a/maintenance-ci/common/scripts/deploy_heat_stack.sh b/maintenance-ci/common/scripts/deploy_heat_stack.sh index a648294..4888775 100755 --- a/maintenance-ci/common/scripts/deploy_heat_stack.sh +++ b/maintenance-ci/common/scripts/deploy_heat_stack.sh @@ -11,13 +11,13 @@ fi parameter_string='' -if [ -z ${IMAGE_NAME} ] ; then +if [ ! -z ${IMAGE_NAME} ] ; then parameter_string="${parameter_string} --parameter 'image=${IMAGE_NAME}'" fi -if [ -z ${FLAVOR_NAME} ] ; then +if [ ! -z ${FLAVOR_NAME} ] ; then parameter_string="${parameter_string} --parameter 'flavor=${FLAVOR_NAME}'" fi -if [ -z ${JENKINS_LABELS} ] ; then +if [ ! -z ${JENKINS_LABELS} ] ; then parameter_string="${parameter_string} --parameter 'jenkins_labels=${JENKINS_LABELS}'" fi diff --git a/maintenance-ci/common/scripts/update-jenkins-jobs.sh b/maintenance-ci/common/scripts/update-jenkins-jobs.sh index f9b4cb7..ef39065 100644 --- a/maintenance-ci/common/scripts/update-jenkins-jobs.sh +++ b/maintenance-ci/common/scripts/update-jenkins-jobs.sh @@ -3,20 +3,17 @@ set -ex pushd maintenance-ci -if [ -z ${GERRIT_REVIEW} ] ; then +if [ ! -z ${GERRIT_REVIEW} ] ; then refspec=$(curl "https://review.fuel-infra.org/changes/?q=${GERRIT_REVIEW}&o=CURRENT_REVISION" | grep '"ref":' | awk -F ": " '{print $2}' | tr -d '"') -git fetch https://review.fuel-infra.org/tools/sustaining "${refspec}" && git cherry-pick FETCH_HEAD +git fetch https://review.fuel-infra.org/tools/sustaining "${refspec}" && git cherry-pick -n FETCH_HEAD fi -tox --help || sudo apt-get install -y python-tox +tox --help >/dev/null || sudo apt-get install -y python-tox tox -e jobs source ".tox/jobs/bin/activate" CONFIG_PATH="${WORKSPACE}/../tmp/${JOB_NAME}" -# JOBS_LIST - Jenkins string parameter. Space separated list of job names to update. -# Will update all jobs if empty. Example: verify-mos-docs docker-rebuild-fuel-ci -JOBS_LIST=(${JOBS_LIST}) umask 0077 mkdir -p "${CONFIG_PATH}" @@ -33,6 +30,6 @@ recursive=True param_order_from_yaml=true EOF -jenkins-jobs --conf "${CONFIG_PATH}/jenkins_jobs.ini" update -x common/data "common:mos:mcp" "${JOBS_LIST[@]}" +jenkins-jobs --conf "${CONFIG_PATH}/jenkins_jobs.ini" update -x common/data "common:mos:mcp" popd diff --git a/maintenance-ci/common/scripts/update-jenkins-views.sh b/maintenance-ci/common/scripts/update-jenkins-views.sh index 7854f2e..2110a18 100644 --- a/maintenance-ci/common/scripts/update-jenkins-views.sh +++ b/maintenance-ci/common/scripts/update-jenkins-views.sh @@ -21,12 +21,6 @@ EOF cd "views/${CI_NAME}" -if [ -n "$VIEWS_LIST" ] ; then - VIEWS_LIST=(${VIEWS_LIST}) -else - VIEWS_LIST=(*) -fi - -jenkins-view-builder update -x common/data --conf "${CONFIG_PATH}/jenkins_jobs.ini" "${VIEWS_LIST[@]}" +jenkins-view-builder update -x common/data --conf "${CONFIG_PATH}/jenkins_jobs.ini" popd -- 2.45.2