blob: bbceb4dfb9bbe26170f81681896a1006b6a07130 [file] [log] [blame]
Linux Foundation Administrators1dc9dd52018-01-26 09:09:09 -08001#!/bin/bash
2# Ubuntu base build
3
4# vim: ts=4 sw=4 sts=4 et tw=72 :
5
6# force any errors to cause the script and job to end in failure
7set -xeu -o pipefail
8
9rh_systems() {
10 echo 'No changes to apply'
11}
12
Zack Williams85249ce2018-04-01 19:54:44 -070013ubuntu_install_java_setup() {
14
15 echo "debconf shared/accepted-oracle-license-v1-1 select true" | debconf-set-selections
16
17 apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys EEA14886
18
19 DISTRO=$(lsb_release -cs)
20
21 apt-add-repository \
22 "deb http://ppa.launchpad.net/webupd8team/java/ubuntu $DISTRO main"
23}
Linux Foundation Administrators1dc9dd52018-01-26 09:09:09 -080024
25ubuntu_systems() {
26 apt-get clean
Linux Foundation Administrators1dc9dd52018-01-26 09:09:09 -080027
Zack Williams85249ce2018-04-01 19:54:44 -070028 # get prereqs for PPA and apt-over-HTTPS support
29 apt-get update
30 apt-get install -y apt-transport-https software-properties-common
31
32 # install java (not needed as SonarQube includes this)
33 # ubuntu_install_java_setup
34 # apt-get update
35 # apt-get install -y oracle-java8-installer
Zack Williams4cfdf202018-05-07 09:58:12 -070036 # rm -rf /var/cache/oracle-jdk8-installer
Luca Prete31860c52018-03-06 17:54:38 -080037
38 # set up ansible repo
Zack Williams85249ce2018-04-01 19:54:44 -070039 apt-add-repository -y ppa:ansible/ansible
Luca Prete31860c52018-03-06 17:54:38 -080040
41 # set up docker repo
Zack Williams85249ce2018-04-01 19:54:44 -070042 apt-key adv --keyserver keyserver.ubuntu.com --recv 0EBFCD88
43 add-apt-repository \
Luca Prete31860c52018-03-06 17:54:38 -080044 "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
45 $(lsb_release -cs) \
46 stable"
47
Zack Williams6ecb83c2018-08-29 13:22:21 -070048 # set up golang repo
49 add-apt-repository ppa:gophers/archive
50
Linux Foundation Administrators1dc9dd52018-01-26 09:09:09 -080051 apt-get update
Luca Prete31860c52018-03-06 17:54:38 -080052
53 # install basic sofware requirements
Linux Foundation Administrators1dc9dd52018-01-26 09:09:09 -080054 apt-get install -y \
Zack Williams85249ce2018-04-01 19:54:44 -070055 "docker-ce=17.06*" \
Luca Prete31860c52018-03-06 17:54:38 -080056 ansible \
Luca Prete31860c52018-03-06 17:54:38 -080057 build-essential \
Linux Foundation Administrators1dc9dd52018-01-26 09:09:09 -080058 bzip2 \
59 curl \
60 git \
Zack Williams6ecb83c2018-08-29 13:22:21 -070061 golang-1.10-go \
Linux Foundation Administrators1dc9dd52018-01-26 09:09:09 -080062 less \
Zack Williams68f43102018-07-07 12:57:13 -070063 libpcap-dev \
Zack Williamscfe0b942018-04-12 11:47:57 -070064 libxml2-utils \
Kailash Khalasi1ddc7c62018-04-20 08:47:56 -070065 maven \
Linux Foundation Administrators1dc9dd52018-01-26 09:09:09 -080066 nodejs \
Linux Foundation Administrators1dc9dd52018-01-26 09:09:09 -080067 npm \
Zack Williams85249ce2018-04-01 19:54:44 -070068 python \
Zack Williams9754a832018-04-13 11:01:59 -070069 python-certifi \
70 python-cryptography \
Luca Prete31860c52018-03-06 17:54:38 -080071 python-dev \
Zack Williams9754a832018-04-13 11:01:59 -070072 python-idna \
Luca Prete31860c52018-03-06 17:54:38 -080073 python-netaddr \
Zack Williams9754a832018-04-13 11:01:59 -070074 python-openssl \
Luca Prete31860c52018-03-06 17:54:38 -080075 python-pip \
Zack Williams9754a832018-04-13 11:01:59 -070076 python-urllib3 \
Zack Williams40c06f02018-04-15 20:31:34 -070077 ruby \
Zack Williamseb842ae2018-05-15 17:07:32 -070078 socat \
Zack Williams85249ce2018-04-01 19:54:44 -070079 ssh \
Luca Prete31860c52018-03-06 17:54:38 -080080 sshpass \
Zack Williams85249ce2018-04-01 19:54:44 -070081 zip
Linux Foundation Administrators1dc9dd52018-01-26 09:09:09 -080082 # end of apt-get install list
Luca Prete31860c52018-03-06 17:54:38 -080083
84 # install python modules
Zack Williams85249ce2018-04-01 19:54:44 -070085 pip install \
86 Jinja2 \
87 ansible-lint \
Zack Williamsac922962018-07-24 13:02:26 -070088 astroid==1.* \
Zack Williams85249ce2018-04-01 19:54:44 -070089 docker-compose==1.20.1 \
90 docker==3.2.1 \
Luca Prete31860c52018-03-06 17:54:38 -080091 gitpython \
Luca Prete90bfa5e2018-03-06 20:41:56 -080092 graphviz \
Kailash Khalasie15b27a2018-06-26 13:28:20 -070093 grpcio-tools \
Zack Williams85249ce2018-04-01 19:54:44 -070094 isort \
Zack Williams6828f822018-04-12 16:13:33 -070095 linkchecker \
Zack Williams85249ce2018-04-01 19:54:44 -070096 pexpect \
Zack Williamse9af4c42018-07-24 14:29:02 -070097 pylint==1.* \
Zack Williams85249ce2018-04-01 19:54:44 -070098 pyyaml \
Luca Prete31860c52018-03-06 17:54:38 -080099 robotframework \
Kailash Khalasicb327c62018-04-03 10:41:38 -0700100 robotframework-httplibrary \
Kailash Khalasia1917682018-08-20 10:34:39 -0700101 robotframework-kafkalibrary \
Zack Williams85249ce2018-04-01 19:54:44 -0700102 robotframework-requests \
Zack Williamsfd8a0042018-04-12 14:34:17 -0700103 robotframework-sshlibrary \
104 virtualenv
Zack Williams85249ce2018-04-01 19:54:44 -0700105 # end of pip install list
Luca Prete31860c52018-03-06 17:54:38 -0800106
Zack Williams40c06f02018-04-15 20:31:34 -0700107 # install ruby gems
108 gem install \
109 mdl
110 # end of gem install list
111
Luca Prete31860c52018-03-06 17:54:38 -0800112 # install npm modules
113 npm install -g \
Zack Williams85249ce2018-04-01 19:54:44 -0700114 gitbook-cli \
115 markdownlint \
Luca Prete31860c52018-03-06 17:54:38 -0800116 typings
Zack Williams85249ce2018-04-01 19:54:44 -0700117 # end of npm install list
Luca Prete31860c52018-03-06 17:54:38 -0800118
Zack Williams6ecb83c2018-08-29 13:22:21 -0700119 # install golang packages in /usr/local/go
120 # Set PATH=$PATH:/usr/local/go/bin` to use these
121 export GOPATH=/usr/local/go
122 mkdir -p $GOPATH
123 export PATH=$PATH:/usr/lib/go-1.10/bin:$GOPATH/bin
124 # converters for unit/coverage test
125 go get -v github.com/t-yuki/gocover-cobertura
126 go get -v github.com/jstemmer/go-junit-report
127
Zack Williams6828f822018-04-12 16:13:33 -0700128 # ubuntu 16.04 installs the node binary as /usr/bin/nodejs, which breaks
129 # tools that expect it to be named just `node`. Symlink it to fix
130 ln -s /usr/bin/nodejs /usr/local/bin/node
131
Luca Prete31860c52018-03-06 17:54:38 -0800132 # install repo
Zack Williams85249ce2018-04-01 19:54:44 -0700133 REPO_SHA256SUM="394d93ac7261d59db58afa49bb5f88386fea8518792491ee3db8baab49c3ecda"
Luca Prete31860c52018-03-06 17:54:38 -0800134 curl -o /tmp/repo 'https://gerrit.opencord.org/gitweb?p=repo.git;a=blob_plain;f=repo;hb=refs/heads/stable'
Zack Williams85249ce2018-04-01 19:54:44 -0700135 echo "$REPO_SHA256SUM /tmp/repo" | sha256sum -c -
136 mv /tmp/repo /usr/local/bin/repo
137 chmod a+x /usr/local/bin/repo
Linux Foundation Administrators1dc9dd52018-01-26 09:09:09 -0800138
Zack Williams85249ce2018-04-01 19:54:44 -0700139 # install sonarqube scanner
Zack Williams891922a2018-07-07 10:33:24 -0700140 # dl link: https://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner
141 SONAR_SCANNER_CLI_VERSION="3.2.0.1227"
142 SONAR_SCANNER_CLI_SHA256SUM="07a50ec270a36cb83f26fe93233819c53c145248c638f4591880f1bd36e331d6"
Zack Williams4cfdf202018-05-07 09:58:12 -0700143 curl -L -o /tmp/sonarscanner.zip "https://sonarsource.bintray.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-${SONAR_SCANNER_CLI_VERSION}-linux.zip"
Zack Williams85249ce2018-04-01 19:54:44 -0700144 echo "$SONAR_SCANNER_CLI_SHA256SUM /tmp/sonarscanner.zip" | sha256sum -c -
145 pushd /opt
146 unzip /tmp/sonarscanner.zip
147 mv sonar-scanner-${SONAR_SCANNER_CLI_VERSION}-linux sonar-scanner
Zack Williams4cfdf202018-05-07 09:58:12 -0700148 rm -f /tmp/sonarscanner.zip
Zack Williams85249ce2018-04-01 19:54:44 -0700149 popd
150
Zack Williams4cfdf202018-05-07 09:58:12 -0700151 # install helm
Zack Williams469fb0d2018-09-10 15:16:51 -0700152 HELM_VERSION="2.10.0"
153 HELM_SHA256SUM="0fa2ed4983b1e4a3f90f776d08b88b0c73fd83f305b5b634175cb15e61342ffe"
Zack Williams8aa52822018-04-05 09:22:15 -0700154 HELM_PLATFORM="linux-amd64"
Zack Williams4cfdf202018-05-07 09:58:12 -0700155 curl -L -o /tmp/helm.tgz "https://storage.googleapis.com/kubernetes-helm/helm-v${HELM_VERSION}-${HELM_PLATFORM}.tar.gz"
Zack Williams8aa52822018-04-05 09:22:15 -0700156 echo "$HELM_SHA256SUM /tmp/helm.tgz" | sha256sum -c -
157 pushd /tmp
158 tar -xzvf helm.tgz
159 mv ${HELM_PLATFORM}/helm /usr/local/bin/helm
160 chmod a+x /usr/local/bin/helm
Zack Williams4cfdf202018-05-07 09:58:12 -0700161 rm -rf helm.tgz ${HELM_PLATFORM}
162 popd
163
Zack Williams4c5bfab2018-05-08 16:13:50 -0700164 # install kubectl
Zack Williams469fb0d2018-09-10 15:16:51 -0700165 KUBECTL_VERSION="1.11.3"
166 KUBECTL_SHA256SUM="0d4c70484e90d4310f03f997b4432e0a97a7f5b5be5c31d281f3d05919f8b46c"
Zack Williams4c5bfab2018-05-08 16:13:50 -0700167 curl -L -o /tmp/kubectl "https://storage.googleapis.com/kubernetes-release/release/v${KUBECTL_VERSION}/bin/linux/amd64/kubectl"
168 echo "$KUBECTL_SHA256SUM /tmp/kubectl" | sha256sum -c -
169 mv /tmp/kubectl /usr/local/bin/kubectl
170 chmod a+x /usr/local/bin/kubectl
171 rm -f /tmp/kubectl
172
Zack Williams4cfdf202018-05-07 09:58:12 -0700173 # install minikube
Zack Williams469fb0d2018-09-10 15:16:51 -0700174 MINIKUBE_VERSION="0.28.2"
Zack Williams4cfdf202018-05-07 09:58:12 -0700175 MINIKUBE_DEB_VERSION="$(echo ${MINIKUBE_VERSION} | sed -n 's/\(.*\)\.\(.*\)/\1-\2/p')"
Zack Williams469fb0d2018-09-10 15:16:51 -0700176 MINIKUBE_SHA256SUM="47cd2db6a65b092a3e1ac47ddd4331914290f04069260ee273530ab7e29123d2"
Zack Williams4cfdf202018-05-07 09:58:12 -0700177 curl -L -o /tmp/minikube.deb "https://storage.googleapis.com/minikube/releases/v${MINIKUBE_VERSION}/minikube_${MINIKUBE_DEB_VERSION}.deb"
178 echo "$MINIKUBE_SHA256SUM /tmp/minikube.deb" | sha256sum -c -
179 pushd /tmp
180 dpkg -i minikube.deb
181 rm -f minikube.deb
Zack Williams8aa52822018-04-05 09:22:15 -0700182 popd
183
Kailash Khalasi929d21b2018-06-28 12:28:17 -0700184 # install protobufs
185 PROTOC_VERSION="3.3.0"
186 PROTOC_SHA256SUM="feb112bbc11ea4e2f7ef89a359b5e1c04428ba6cfa5ee628c410eccbfe0b64c3"
187 curl -L -o /tmp/protoc-${PROTOC_VERSION}-linux-x86_64.zip https://github.com/google/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-x86_64.zip
188 echo "$PROTOC_SHA256SUM /tmp/protoc-${PROTOC_VERSION}-linux-x86_64.zip" | sha256sum -c -
Kailash Khalasic4ff32d2018-06-28 18:24:52 -0700189 unzip /tmp/protoc-${PROTOC_VERSION}-linux-x86_64.zip -d /tmp/protoc3
Kailash Khalasi929d21b2018-06-28 12:28:17 -0700190 mv /tmp/protoc3/bin/* /usr/local/bin/
191 mv /tmp/protoc3/include/* /usr/local/include/
192 # give sudo permissions on minikube and protoc to jenkins user
193 cat <<EOF >/etc/sudoers.d/88-jenkins-minikube-protoc
194Cmnd_Alias CMDS = /usr/local/bin/protoc, /usr/bin/minikube
Zack Williams81739772018-05-14 16:35:47 -0700195Defaults:jenkins !requiretty
Kailash Khalasi929d21b2018-06-28 12:28:17 -0700196jenkins ALL=(ALL) NOPASSWD:SETENV: CMDS
Zack Williams81739772018-05-14 16:35:47 -0700197EOF
198
Zack Williams85249ce2018-04-01 19:54:44 -0700199 # clean up
200 apt-get clean
201 apt-get purge -y
202 apt-get autoremove -y
203 rm -rf /var/lib/apt/lists/*
Linux Foundation Administrators1dc9dd52018-01-26 09:09:09 -0800204}
Zack Williams85249ce2018-04-01 19:54:44 -0700205
Linux Foundation Administrators1dc9dd52018-01-26 09:09:09 -0800206all_systems() {
207 echo 'No common distribution configuration to perform'
208}
209
210echo "---> Detecting OS"
211ORIGIN=$(facter operatingsystem | tr '[:upper:]' '[:lower:]')
212
213case "${ORIGIN}" in
214 fedora|centos|redhat)
215 echo "---> RH type system detected"
216 rh_systems
217 ;;
218 ubuntu)
219 echo "---> Ubuntu system detected"
220 ubuntu_systems
221 ;;
222 *)
223 echo "---> Unknown operating system"
224 ;;
225esac
226
227# execute steps for all systems
228all_systems