Skip to content

Commit 16f9b26

Browse files
Merge pull request #9624 from sharifelgamal/install-docker
Add script to automatically install docker on jenkins machines
2 parents a73f2c1 + b226a79 commit 16f9b26

File tree

3 files changed

+39
-1
lines changed

3 files changed

+39
-1
lines changed

hack/jenkins/common.sh

+3
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ export PATH=$PATH:"/usr/local/bin/:/usr/local/go/bin/:$GOPATH/bin"
3333
# installing golang so we could do go get for gopogh
3434
sudo ./installers/check_install_golang.sh "1.15.2" "/usr/local" || true
3535

36+
# install docker and kubectl if not present
37+
sudo ./installers/check_install_docker.sh
38+
3639
docker rm -f -v $(docker ps -aq) >/dev/null 2>&1 || true
3740
docker volume prune -f || true
3841
docker system df || true
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/bash
2+
3+
# Copyright 2016 The Kubernetes Authors All rights reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
set -eux -o pipefail
18+
19+
if [[ "$OSTYPE" == "darwin"* ]]; then
20+
echo "detected darwin, exiting"
21+
return
22+
fi
23+
24+
echo "Installing latest docker"
25+
sudo apt-get -y update
26+
sudo apt-get -y install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
27+
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -
28+
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian `lsb_release -cs` stable"
29+
sudo apt-get -y update
30+
sudo apt-get -y install docker-ce docker-ce-cli containerd.io
31+
sudo usermod -aG docker jenkins
32+
33+
echo "Installing latest kubectl"
34+
curl -LO "https://storage.googleapis.com/kubernetes-release/release/`curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt`/bin/linux/amd64/kubectl"
35+
sudo install ./kubectl /usr/local/bin/kubectl

hack/jenkins/installers/check_install_golang.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ set -eux -o pipefail
1818

1919
if (($# < 2)); then
2020
echo "ERROR: given ! ($#) number of parameters but expect 2."
21-
echo "USAGE: ./check_and_install_golang.sh VERSION_TO_INSTALL INSTALL_PATH"
21+
echo "USAGE: ./check_install_golang.sh VERSION_TO_INSTALL INSTALL_PATH"
2222
exit 1
2323
fi
2424

0 commit comments

Comments
 (0)