Files
project-config/nodepool/elements/jenkins-slave/install.d/20-jenkins-slave
Clark Boylan 86877df4af Only configure jenkins cache if cache exists
Users may not want to build images with a cache as it significantly
slows down the build process and results in far larger images. Currently
we don't depend on cache-devstack in the jenkins-slave element for this
reason. Unfortunately we assume cache-devstack was run because we
attempt to link to a directory created by this element.

Update jenkins-slave to only make the link if the cache dir exists to
address this. Users can now make cacheless images quickly and cheaply.

Change-Id: I45ec2fcd614d71f1db85cab3c5c3730a96c8fd61
2017-06-20 09:28:09 -07:00

52 lines
1.4 KiB
Bash
Executable File

#!/bin/bash
if [ ${DIB_DEBUG_TRACE:-0} -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
# Add jenkins user and group. Note we don't want to rely on
# "useradd"'s group adding behaviour, because it might differ across
# distros.
groupadd jenkins
useradd -g jenkins -m jenkins -s /bin/bash
# a lot of caching happens in extra-data.d (for "historical" reasons).
# We've put the cache stuff into /opt/cache/files, but again, for
# "historical" reasons, ensure this is available in /home/jenkins
#
# Check if the cache exists as we don't have a strict dependency on the
# devstack-cache element. This allows you to build an image without
# incurring the cost of caching all the things.
if [ -d /opt/cache/files ] ; then
mkdir -p /home/jenkins/cache
ln -sf /opt/cache/files /home/jenkins/cache/files
chown -R jenkins:jenkins /opt/cache/files
fi
# this was copied from outside the chroot by extras.d
_pub_key=/tmp/in_target.d/jenkins-user-ssh-public-key
if [ ! -f $_pub_key ]; then
die "Can not find Jenkins public key!"
fi
mkdir /home/jenkins/.ssh
chmod 700 /home/jenkins/.ssh
cp $_pub_key /home/jenkins/.ssh/authorized_keys
chmod 644 /home/jenkins/.ssh/authorized_keys
cat > /home/jenkins/.gitconfig <<EOF
[user]
name = OpenStack Jenkins
email = jenkins@openstack.org
signingkey = jenkins@openstack.org
[gitreview]
rebase = false
username = jenkins
EOF
# cleanup everything to the right owner
chown -R jenkins:jenkins /home/jenkins