From: Tim Johnson Date: Tue, 5 Mar 2019 22:46:52 +0000 (-0800) Subject: Update Jenkins Init Scripts X-Git-Tag: v0.33.0~2 X-Git-Url: https://gerrit.linuxfoundation.org/infra/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F78%2F14778%2F5;p=releng%2Fglobal-jjb.git Update Jenkins Init Scripts Support ability to specify swap size and to pre-allocate the '/w' volume for the Hyperledger Project Change-Id: I04af514bbb237f405eb1d31ec10e3f019c85a43e Signed-off-by: Tim Johnson --- diff --git a/jenkins-init-scripts/create-jenkins-user.sh b/jenkins-init-scripts/create-jenkins-user.sh index 00052442..0983129f 100755 --- a/jenkins-init-scripts/create-jenkins-user.sh +++ b/jenkins-init-scripts/create-jenkins-user.sh @@ -29,10 +29,14 @@ if grep -q mock /etc/group; then usermod -a -G mock jenkins fi -mkdir /home/jenkins/.ssh /w +mkdir /home/jenkins/.ssh cp -r "/home/${OS}/.ssh/authorized_keys" /home/jenkins/.ssh/authorized_keys # Generate ssh key for use by Robot jobs echo -e 'y\n' | ssh-keygen -N "" -f /home/jenkins/.ssh/id_rsa -t rsa -chown -R jenkins:jenkins /home/jenkins/.ssh /w +chown -R jenkins:jenkins /home/jenkins/.ssh chmod 700 /home/jenkins/.ssh + +# The '/w' volume may already be part of image +[[ ! -d '/w' ]] && mkdir /w +chown -R jenkins:jenkins /w diff --git a/jenkins-init-scripts/create-swap-file.sh b/jenkins-init-scripts/create-swap-file.sh index cf8d97f1..6f077388 100755 --- a/jenkins-init-scripts/create-swap-file.sh +++ b/jenkins-init-scripts/create-swap-file.sh @@ -9,7 +9,22 @@ # http://www.eclipse.org/legal/epl-v10.html ############################################################################## -dd if=/dev/zero of=/swap count=1024 bs=1MiB +# Get the blockCount from the 'SWAP_SIZE' environmental variable +blockCount=${SWAP_SIZE-''} + +# Validate SWAP_SIZE +# Empty: Set blockCount 1 +# Zero: No Swap +# Integer: Set blockCount +# Else: No Swap +case $blockCount in + '') blockCount=1 ;; + [0-9]*) blockCount=$blockCount ;; + *) exit ;; +esac +[[ $blockCount == 0 ]] && exit + +dd if=/dev/zero of=/swap count="${blockCount}k" bs=1MiB chmod 600 /swap mkswap /swap swapon /swap diff --git a/releasenotes/notes/custom-swap-size-864fc8ca8343d4af.yaml b/releasenotes/notes/custom-swap-size-864fc8ca8343d4af.yaml new file mode 100644 index 00000000..9ff6a47a --- /dev/null +++ b/releasenotes/notes/custom-swap-size-864fc8ca8343d4af.yaml @@ -0,0 +1,11 @@ +--- +prelude: + - | + Previously the swap size was fixed at 1GB. +features: + - | + If the environmental variable 'SWAP_SIZE' is set when the + 'init.sh' script is called, then a 'SWAP_SIZE' GB swap space will + be configured. If 'SWAP_SIZE' is '0' or is not a valid integer, + then no swap space is cofigured. If it is unset then 1GB of swap + will be configured. diff --git a/releasenotes/notes/pre-existing-work-volume-05af4e8546facbea.yaml b/releasenotes/notes/pre-existing-work-volume-05af4e8546facbea.yaml new file mode 100644 index 00000000..b09c1016 --- /dev/null +++ b/releasenotes/notes/pre-existing-work-volume-05af4e8546facbea.yaml @@ -0,0 +1,9 @@ +--- +prelude: + - | + The work directory (/w) was created in the '/' volume. The ownership was + set to 'jenkins:jenkins'. +features: + - | + If the work directory or volume (/w) aleady exists, the ownership will be + recursivly set to 'jenkins:jenkins'.