Enable merge jobs to trigger downstream job
[ci-management.git] / jjb / iec / iec-seba_on_arm.sh
1 #!/bin/bash
2 # SPDX-license-identifier: Apache-2.0
3 ##############################################################################
4 # Copyright (c) 2019 Enea Software AB and others.
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
9 ##############################################################################
10
11 export TERM="vt220"
12
13 echo "JOB_NAME=${JOB_NAME}"
14
15 case "${JOB_NAME}" in
16   *fuel*)
17     K8S_MASTER_IP=$(docker exec fuel cat /etc/hosts | grep iec01 \
18                     | awk '{print $1}')
19     # On Fuel deployements the K8s ssh key is the one used by the deploy job
20     K8S_SSH_KEY=${SSH_KEY}
21     IEC_DIR="/home/${K8S_SSH_USER}/iec"
22     ;;
23   *compass*)
24     K8S_MASTER_IP=${K8S_MASTER_IP_COMPASS}
25     K8S_SSH_USER=${K8S_SSH_USER_COMPASS}
26     K8S_SSH_PASSWORD=${K8S_SSH_PASSWORD_COMPASS}
27     IEC_DIR="/${K8S_SSH_USER_COMPASS}/iec"
28     ;;
29   *)
30     echo "Cannot determine installer from ${JOB_NAME}"
31     exit 1
32     ;;
33 esac
34
35 if [ -z "$K8S_SSH_USER" ]
36 then
37   echo "K8S_SSH_USER not set, cannot ssh to install SEBA"
38   exit 1
39 fi
40
41 INSTALL_CMD="cd ${IEC_DIR}/src/use_cases/seba_on_arm/install; ./install.sh"
42
43 if [ -n "${K8S_SSH_PASSWORD}" ]
44 then
45   sshpass -p "${K8S_SSH_PASSWORD}" ssh -o StrictHostKeyChecking=no \
46     "${K8S_SSH_USER}"@"${K8S_MASTER_IP}" "${INSTALL_CMD}"
47 elif [ -n "${K8S_SSH_KEY}" ]
48 then
49   ssh -o StrictHostKeyChecking=no -i "${K8S_SSH_KEY}" \
50     "${K8S_SSH_USER}"@"${K8S_MASTER_IP}" "${INSTALL_CMD}"
51 else
52   echo "Neither K8S_SSH_USER or K8S_SSH_KEY set. Cannot ssh to K8S Master"
53   exit 1
54 fi
55
56 exit 0