X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=jjb%2Fshell%2Fpackagecloud-push.sh;h=beb94676fee5af55216cb004e1cf2b0a6f2fdcc3;hb=refs%2Fheads%2Fmaster;hp=a48d39cffdf39b854bf35b9850f8d6f034275277;hpb=41b9c4242096cd37a15da130ac70a805fdc8fb5c;p=ci-management.git diff --git a/jjb/shell/packagecloud-push.sh b/jjb/shell/packagecloud-push.sh index a48d39cf..beb94676 100755 --- a/jjb/shell/packagecloud-push.sh +++ b/jjb/shell/packagecloud-push.sh @@ -1,41 +1,53 @@ #!/bin/bash -l # SPDX-License-Identifier: EPL-1.0 ############################################################################## -# Copyright (c) 2019 The Linux Foundation and others. +# Copyright (c) 2020 The Linux Foundation and others. # # All rights reserved. This program and the accompanying materials # are made available under the terms of the Eclipse Public License v1.0 # which accompanies this distribution, and is available at # http://www.eclipse.org/legal/epl-v10.html ############################################################################## + +# Prereqs: +# The build minion has the ruby gem "package_cloud" +# The required credentials and API files have been provisioned +# The build directory has .deb/.rpm files +# Environment variables: +# BUILD_DIR is set and non-empty +# DEBIAN_DISTRIBUTION_VERSIONS has distro list like "debian/stretch" +# RPM_DISTRIBUTION_VERSIONS has distro list like "el/4 el/5" +# PACKAGECLOUD_ACCOUNT is set and non-empty +# PACKAGECLOUD_REPO is a value like "staging" + echo "---> packagecloud-push.sh" set -eu -o pipefail -if [ ! -f ~/.packagecloud ]; then - echo "INFO: .packagecloud file not found" - exit 0 -fi - - # For DEB -vers=("$DEBIAN_DISTRIBUTION_VERSIONS") -echo "Debian distribution versions:" "${vers[@]}" -debs=$(find . -type f -iname '*.deb') -# modern bash syntax is helpful -for (( i = 0; i < ${#vers[@]}; i++ )); do - for deb in $debs; do - echo "Pushing $deb $PACKAGECLOUD_ACCOUNT/$PACKAGECLOUD_REPO/${vers[i]}" - package_cloud push "$PACKAGECLOUD_ACCOUNT"/"$PACKAGECLOUD_REPO"/"${vers[i]}" "$deb" +# Pushes packages to PackageCloud +# $1 is a shell-style glob pattern for package files +# $2 is a space-separated list of distribution versions +push_packages () { + echo "Expanding file pattern $1" + # shellcheck disable=SC2206 + pkgs=($1) + if [[ ! -f ${pkgs[0]} ]]; then + echo "WARN: no files matched pattern $1" + return + fi + echo "Found package file(s):" "${pkgs[@]}" + echo "Processing distribution version(s): $2" + for ver in $2; do + arg="${PACKAGECLOUD_ACCOUNT}/${PACKAGECLOUD_REPO}/${ver}" + for pkg in "${pkgs[@]}"; do + echo "Pushing $arg $pkg" + package_cloud push "$arg" "$pkg" + done done -done +} -# For RPM -vers=("$RPM_DISTRIBUTION_VERSIONS") -echo "RPM distribution versions:" "${vers[@]}" -rpms=$(find . -type f -iregex '.*/.*\.\(s\)?rpm') -# modern bash syntax is helpful -for (( i = 0; i < ${#vers[@]}; i++ )); do - for rpm in $rpms; do - echo "Pushing $rpm $PACKAGECLOUD_ACCOUNT/$PACKAGECLOUD_REPO/${vers[i]}" - package_cloud push "$PACKAGECLOUD_ACCOUNT"/"$PACKAGECLOUD_REPO"/"${vers[i]}" "$rpm" - done -done +echo "Working in directory $BUILD_DIR" +cd "$BUILD_DIR" +push_packages "*.deb" "$DEBIAN_DISTRIBUTION_VERSIONS" +push_packages "*.rpm" "$RPM_DISTRIBUTION_VERSIONS" + +echo "---> packagecloud-push.sh ends"