3 # Copyright (c) 2021 Cisco and/or its affiliates.
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at:
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
16 echo "---> jjb/scripts/packagecloud_push.sh"
20 line="*************************************************************************"
22 # Nothing was built if this is a merge job being run when
23 # the git HEAD id is not the same as the Gerrit New Revision ID
24 if [[ ${JOB_NAME} == *merge* ]] && [ -n "${GERRIT_NEWREV:-}" ] &&
25 [ "$GERRIT_NEWREV" != "$GIT_COMMIT" ] ; then
26 echo -e "\n$line\nSkipping package push. A newer patch has been merged.\n$line\n"
31 if [ "${DRYRUN,,}" = "true" ] ; then
32 echo -e "\n$line\nSkipping package push because DRYRUN is '${DRYRUN,,}'.\n$line\n"
36 echo "STARTING PACKAGECLOUD PUSH"
40 FACTER_OS=$(/usr/bin/facter operatingsystem)
44 # PCIO_CO and SILO are Jenkins Global Environment variables defined in
45 # .../ci-management/jenkins-config/global-vars-*.sh
46 if [ -f ~/.packagecloud ]; then
49 FACTER_LSBNAME=$(/usr/bin/facter lsbdistcodename)
50 DEBS=$(find . -type f -iname '*.deb' | grep -v vpp-ext-deps)
51 push_cmd="package_cloud push ${PCIO_CO}/${STREAM}/debian/${FACTER_LSBNAME}/main/ ${DEBS}"
52 EXT_DEPS_DEB=$(find . -type f -iname 'vpp-ext-deps*.deb')
53 if [ -n "$EXT_DEPS_DEB" ] ; then
54 push_ext_deps_cmd="package_cloud push ${PCIO_CO}/${STREAM}/debian/${FACTER_LSBNAME}/main/ ${EXT_DEPS_DEB}"
58 FACTER_LSBNAME=$(/usr/bin/facter lsbdistcodename)
59 DEBS=$(find . -type f -iname '*.deb' | grep -v vpp-ext-deps)
60 push_cmd="package_cloud push ${PCIO_CO}/${STREAM}/ubuntu/${FACTER_LSBNAME}/main/ ${DEBS}"
61 EXT_DEPS_DEB=$(find . -type f -iname 'vpp-ext-deps*.deb')
62 if [ -n "$EXT_DEPS_DEB" ] ; then
63 push_ext_deps_cmd="package_cloud push ${PCIO_CO}/${STREAM}/ubuntu/${FACTER_LSBNAME}/main/ ${EXT_DEPS_DEB}"
67 FACTER_OSMAJREL=$(/usr/bin/facter operatingsystemmajrelease)
68 FACTER_ARCH=$(/usr/bin/facter architecture)
69 RPMS=$(find . -type f -iregex '.*/.*\.\(s\)?rpm' | grep -v vpp-ext-deps)
70 push_cmd="package_cloud push ${PCIO_CO}/${STREAM}/el/${FACTER_OSMAJREL}/os/${FACTER_ARCH}/ ${RPMS}"
71 EXT_DEPS_RPM=$(find . -type f -iname 'vpp-ext-deps*.rpm')
72 if [ -n "$EXT_DEPS_RPM" ] ; then
73 push_ext_deps_cmd="package_cloud push ${PCIO_CO}/${STREAM}/el/${FACTER_OSMAJREL}/os/${FACTER_ARCH}/ ${EXT_DEPS_RPM}"
77 echo -e "\n$line\n* ERROR: Unsupported OS '$FACTER_OS'\n* PACKAGECLOUD PUSH FAILED!\n$line\n"
81 if [ "${SILO,,}" = "sandbox" ] ; then
82 echo "SANDBOX: skipping '$push_cmd'"
83 if [ -n "$push_ext_deps_cmd" ] ; then
84 echo "SANDBOX: skipping '$push_ext_deps_cmd'"
88 if [ -n "$push_ext_deps_cmd" ] ; then
89 # Don't fail script if vpp-ext-deps push fails.
96 echo "ERROR: Missing '~/.packagecloud' for user '$(id)'"
97 echo "PACKAGECLOUD PUSH FAILED!"
101 echo -e "\n$line\n* PACKAGECLOUD PUSH COMPLETE\n$line\n"