2015-02-09 17:39:25 +01:00
|
|
|
#!/bin/bash -x
|
2015-04-27 10:08:19 +02:00
|
|
|
|
2017-02-06 09:01:21 -08:00
|
|
|
if [ $(id -u) != 0 ]; then
|
|
|
|
# preserve environment to keep ZUUL_* params
|
|
|
|
export SUDO='sudo -E'
|
|
|
|
fi
|
|
|
|
|
|
|
|
# if we're in an integration gate, we're using OpenStack mirrors
|
|
|
|
if [ -f /etc/nodepool/provider ]; then
|
|
|
|
source /etc/nodepool/provider
|
|
|
|
NODEPOOL_MIRROR_HOST=${NODEPOOL_MIRROR_HOST:-mirror.$NODEPOOL_REGION.$NODEPOOL_CLOUD.openstack.org}
|
|
|
|
NODEPOOL_MIRROR_HOST=$(echo $NODEPOOL_MIRROR_HOST|tr '[:upper:]' '[:lower:]')
|
|
|
|
CENTOS_MIRROR_HOST=${NODEPOOL_MIRROR_HOST}
|
|
|
|
UCA_MIRROR_HOST="${NODEPOOL_MIRROR_HOST}/ubuntu-cloud-archive"
|
|
|
|
CEPH_MIRROR_HOST="${NODEPOOL_MIRROR_HOST}/ceph-deb-jewel"
|
2017-11-27 08:33:12 -08:00
|
|
|
NODEPOOL_RDO_PROXY=${NODEPOOL_RDO_PROXY}
|
|
|
|
NODEPOOL_RUBYGEMS_PROXY=${NODEPOOL_RUBYGEMS_PROXY}
|
2017-02-06 09:01:21 -08:00
|
|
|
else
|
|
|
|
CENTOS_MIRROR_HOST='mirror.centos.org'
|
|
|
|
UCA_MIRROR_HOST='ubuntu-cloud.archive.canonical.com/ubuntu'
|
|
|
|
CEPH_MIRROR_HOST='download.ceph.com/debian-jewel'
|
|
|
|
fi
|
|
|
|
|
2015-06-23 12:02:08 -05:00
|
|
|
# The following will handle cross cookbook patch dependencies via the Depends-On in commit message
|
|
|
|
|
|
|
|
# ZUUL_CHANGES has a ^ separated list of patches, the last being the current patch.
|
|
|
|
# The Depends_On will add patches to the front of this list.
|
|
|
|
echo $ZUUL_CHANGES
|
|
|
|
# Convert string list to array
|
|
|
|
cookbooks=(${ZUUL_CHANGES//^/ })
|
|
|
|
# Remove the last one as it's the current cookbook
|
|
|
|
# TODO(MRV) At some point we could consider removing the gerrit-git-prep step from the rake job
|
|
|
|
# and also doing that patch clone with zuul-cloner. After gerrit-git-prep is removed, need to
|
|
|
|
# remove this unset line and adjust the clone map to have the base patch put into the current dir.
|
|
|
|
unset cookbooks[${#cookbooks[@]}-1]
|
|
|
|
|
|
|
|
# Create clone map
|
|
|
|
cat > clonemap.yaml <<EOF
|
|
|
|
clonemap:
|
|
|
|
- name: 'openstack/(.*)'
|
|
|
|
dest: '\1'
|
|
|
|
EOF
|
|
|
|
|
|
|
|
# Create list of Depends-On cookbook names and update Berksfile entry for each
|
|
|
|
cookbook_projects=""
|
|
|
|
for cookbook_info in "${cookbooks[@]}"; do
|
|
|
|
[[ $cookbook_info =~ openstack/([a-z-]*):.* ]]
|
|
|
|
cookbook_name="${BASH_REMATCH[1]}"
|
2017-10-05 09:43:52 +00:00
|
|
|
if [ -n "$cookbook_name" ]; then
|
2017-10-04 07:46:03 +00:00
|
|
|
cookbook_projects+=" openstack/$cookbook_name"
|
|
|
|
sed -i -e "s|github: [\"\']openstack/$cookbook_name[\"\']|path: '../$cookbook_name'|" Berksfile
|
|
|
|
fi
|
2015-06-23 12:02:08 -05:00
|
|
|
done
|
|
|
|
|
|
|
|
# Allow the zuul cloner to pull down the necessary Depends-On patches
|
2016-03-11 13:44:03 -08:00
|
|
|
#
|
|
|
|
# also change ownership of .chef and workspace
|
2015-06-23 12:02:08 -05:00
|
|
|
if [ "$cookbook_projects" ]
|
|
|
|
then
|
|
|
|
sudo -E /usr/zuul-env/bin/zuul-cloner \
|
|
|
|
-m clonemap.yaml \
|
|
|
|
--cache-dir /opt/git \
|
|
|
|
--workspace /home/jenkins/workspace/ \
|
2019-03-24 20:33:22 +00:00
|
|
|
https://git.openstack.org \
|
2016-03-11 13:44:03 -08:00
|
|
|
$cookbook_projects && \
|
|
|
|
sudo chown -R jenkins:jenkins /home/jenkins/workspace && \
|
|
|
|
sudo mkdir -p /home/jenkins/.chef && \
|
|
|
|
sudo chown -R jenkins:jenkins /home/jenkins/.chef
|
2015-06-23 12:02:08 -05:00
|
|
|
fi
|