Add bff stage release job to ci-management
[ci-management.git] / jenkins-scripts / nexus3_port_forwarding.sh
1 #!/bin/bash
2 # SPDX-License-Identifier: EPL-1.0
3 ##############################################################################
4 # Copyright (c) 2019 The Linux Foundation and others.
5 #
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Eclipse Public License v1.0
8 # which accompanies this distribution, and is available at
9 # http://www.eclipse.org/legal/epl-v10.html
10 ##############################################################################
11 echo "---> nexus3_port_forwarding.sh"
12 set +e  # DON'T fail build if script fails.
13
14 NEXUS3_IP=`host nexus3.onap.org | awk '/has address/ { print $4 ; exit }'`
15 OS_ARCH=$(ANSIBLE_STDOUT_CALLBACK=json ANSIBLE_LOAD_CALLBACK_PLUGINS=1 \
16     ansible all -i "localhost," --connection=local -m setup | jq -r \
17     '.. | .ansible_architecture? | select(type != "null")' \
18     | tr '[:upper:]' '[:lower:]')
19
20
21 if [[ "${OS_ARCH}" == "aarch64" ]] ;then
22   echo "os_arch: $OS_ARCH"
23   iptables -t nat -I OUTPUT 1 -p tcp -d ${NEXUS3_IP} --dport 10001 -j DNAT --to-destination ${NEXUS3_IP}:11001
24   iptables -t nat -I OUTPUT 1 -p tcp -d ${NEXUS3_IP} --dport 10002 -j DNAT --to-destination ${NEXUS3_IP}:11002
25   iptables -t nat -I OUTPUT 1 -p tcp -d ${NEXUS3_IP} --dport 10003 -j DNAT --to-destination ${NEXUS3_IP}:11003
26 fi
27
28 # DON'T fail build if script fails.
29 exit 0