Add build folder for ONAP Offline Build Jobs
[infra/cicd.git] / jjb / onap-offline / build_jobs / scripts / 5_build_create_package.sh
1 #!/bin/bash
2
3 set -x
4
5 ### Setting up variables used in this script ###
6 build_node_ip=$(openstack server list -c Name -c Networks -f value | egrep ${openstack_build_stack_name} | awk '{print $NF}' | sed 's/.*=//g')
7 ssh_cmd="ssh -o StrictHostKeychecking=no -i ${ssh_key} ${remote_user}@${build_node_ip}"
8
9 ### Tarring up the files refer to package_oom_cmd for oom version used ###
10 RESULT=$(${ssh_cmd} "${package_oom_cmd} --output-dir /tmp/data --resources-directory ${resources_dir}")
11 if [[ $? -ne 0 ]]; then
12   ### /tmp/data might be already used, thus clean it up and restart again ###
13   ${ssh_cmd} "sudo bash -c \"rm -rf /tmp/data\""
14   ${ssh_cmd} "${package_oom_cmd} --output-dir /tmp/data --resources-directory ${resources_dir}"
15   if [[ $? -ne 0 ]]; then
16   echo "failed to successfully run package.py"
17   exit -1
18   fi
19 fi
20
21 ### Since the values.yaml has pnda set to false (due to issues with the website) the package created contains a different name than used usually ###
22 ### Need to change the name of the tar files ###
23
24 ${ssh_cmd} "sudo bash -c \"test -f /tmp/data/resources_packagecustom.tar\""
25 if [[ $? -eq 0 ]]; then
26   echo "There is a custom package";
27   ${ssh_cmd} "sudo bash -c \"mv /tmp/data/resources_packagecustom.tar /tmp/data/resources_package.tar\"";
28 fi
29
30 ${ssh_cmd} "sudo bash -c \"test -f /tmp/data/sw_packagecustom.tar\""
31 if [[ $? -eq 0 ]]; then
32   echo "There is a custom package";
33   ${ssh_cmd} "sudo bash -c \"mv /tmp/data/sw_packagecustom.tar /tmp/data/sw_package.tar\"";
34 fi