3 # Copyright (c) 2020 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.
18 export CIMAN_DOCKER_SCRIPTS=${CIMAN_DOCKER_SCRIPTS:-"$(dirname $BASH_SOURCE)"}
19 . $CIMAN_DOCKER_SCRIPTS/lib_common.sh
22 must_be_run_in_docker_build
24 # Add jenkins user and make it equivalent to root
25 groupadd jenkins || true
26 useradd -m -s /bin/bash -g jenkins jenkins || true
28 ln -s /root /home/jenkins
30 # Add packagecloud files
31 cat <<EOF > /root/.packagecloud
32 {"url":"https://packagecloud.io","token":"\$token"}
34 cat <<EOF >/root/packagecloud_api
35 machine packagecloud.io
40 # Check if docker group exists
41 if grep -q docker /etc/group
43 # Add jenkins user to docker group
44 usermod -a -G docker jenkins
47 # Check if mock group exists
48 if grep -q mock /etc/group
50 # Add jenkins user to mock group so it can build RPMs
51 # using mock if available
52 usermod -a -G mock jenkins
55 # Give jenkins account root privileges
56 jenkins_uid=$(id -u jenkins)
57 perl -i -p -e "s/$jenkins_uid\:/0\:/g" /etc/passwd
59 # Copy lf-env.sh for LF Releng scripts
60 cp $DOCKER_CIMAN_ROOT/global-jjb/jenkins-init-scripts/lf-env.sh /root
61 chmod 644 /root/lf-env.sh
63 # Install lftools[openstack] -- from global-jjb/shell/python-tools-install.sh
65 if [ "$OS_NAME" = "debian-9" } ; then
66 # debian-9 does not have osc-lib==2.2.0 available breaking docker image
67 # build so pin the version of lftools which does not pin osc-lib==2.2.0
68 pinned_version="==0.34.1"
70 python3 -m pip install --no-deps lftools[openstack]$pinned_version