add ccsdk-sli-northbound
[infra/cicd.git] / jjb / onap-offline / build_jobs / scripts / 2_build_preparation.sh
1 #!/bin/bash
2
3 ### Some other ways to get build_node_ip in case you don't want to make a file on Jenkins server ###
4 #build_node_ip=$(openstack server list -c Name -c Networks -f value | egrep ${stack_name} | awk '{print $NF}')
5 #build_node_ip=$(openstack server show ${stack_name} -f value -c addresses | cut -d' ' -f2 )
6
7 ### Setting variables used in this script ###
8 build_node_ip=$(openstack server list -c Name -c Networks -f value | egrep ${openstack_build_stack_name} | awk '{print $NF}' | sed 's/.*=//g')
9 ssh_cmd="ssh -o StrictHostKeychecking=no -i ${ssh_key} ${remote_user}@${build_node_ip}"
10 docker_repo="https://download.docker.com/linux/centos/docker-ce.repo"
11
12 ####################################
13 ### PREPARATIONS FOR CENTOS ONLY ###
14 ####################################
15
16 ### Required by special centos docker recommended by ONAP ###
17 RESULT=$(${ssh_cmd} "sudo yum-config-manager --add-repo ${docker_repo}")
18 if [[ $? -ne 0 ]]; then
19   echo "Failed to install add repo successfully: $RESULT"
20   exit -1
21 fi
22
23 ### Enable epel repo for npm and jq ###
24 RESULT=$(${ssh_cmd} "sudo yum install -y epel-release")
25 if [[ $? -ne 0 ]]; then
26   echo "Failed to install epel-release successfully: $RESULT"
27   exit -1
28 fi
29
30 ### Install following packages ###
31 RESULT=$(${ssh_cmd} "sudo yum install -y docker-ce-18.09.5 python-pip git createrepo expect nodejs npm jq")
32 if [[ $? -ne 0 ]]; then
33   echo "Failed to install packages successfully: $RESULT"
34   exit -1
35 fi
36
37 ### Offline Installer is using python3 now, thus need to install python3 and pip3 ###
38 RESULT=$(${ssh_cmd} "sudo yum install -y python36 python36-pip")
39 if [[ $? -ne 0 ]]; then
40   echo "Failed to install packages: $RESULT"
41   exit -1
42 fi
43
44 ### Install Twine, specific version 1.15.0 used, because new version 2.0.0 breaks the installation ###
45 RESULT=$(${ssh_cmd} "sudo pip install twine==1.15.0")
46 if [[ $? -ne 0 ]]; then
47   echo "Failed to pip install twine: $RESULT"
48   exit -1
49 fi
50
51 ### Starting Docker Service ###
52 RESULT=$(${ssh_cmd} "sudo service docker start")
53 if [[ $? -ne 0 ]]; then
54   echo "Failed to pip install twine: $RESULT"
55   exit -1
56 fi
57
58 ### Clone the OFfline Installer repo ###
59 RESULT=$(${ssh_cmd} " sudo git clone https://gerrit.onap.org/r/oom/offline-installer /tmp/onap-offline")
60 if [[ $? -ne 0 ]]; then
61   echo "Failed to clone onap/offline/install repo: $RESULT"
62   exit -1
63 fi
64 sleep 5
65
66 ### Install the required python packages ###
67 RESULT=$(${ssh_cmd} "sudo pip3 install -r /tmp/onap-offline/build/requirements.txt")
68 if [[ $? -ne 0 ]]; then
69   echo "Failed to install: $RESULT"
70   exit -1
71 fi
72 RESULT=$(${ssh_cmd} "sudo pip3 install -r /tmp/onap-offline/build/download/requirements.txt")
73 if [[ $? -ne 0 ]]; then
74   echo "Failed to install: $RESULT"
75   exit -1
76 fi