#!/bin/bash

set -e

#cd /home/reghao/Downloads
#git clone https://git.reghao.cn/reghao/devops

base_dir='/home/reghao/Downloads/devops'
#base_dir='/home/reghao/code/java/devops'
cd ${base_dir}
mvn clean package -Dmaven.test.skip=true -Ptest
#
cd ${base_dir}/deployer/bin

manager_local_dir=${base_dir}'/manager/bin'
manager_remote_dir='/opt/apps/devops-web1'
manager_server_file='/home/reghao/Downloads/servers1.csv'
java -jar devops-deployer.jar "devops-web" ${manager_local_dir} ${manager_remote_dir} ${manager_server_file}

#agent_local_dir=${base_dir}'/agent/bin'
#agent_remote_dir='/opt/apps/devops-agent1'
#agent_servers_file='/home/reghao/Downloads/servers3.csv'
#java -jar devops-deployer.jar "devops-agent" ${agent_local_dir} ${agent_remote_dir} ${agent_servers_file}

cd ${base_dir}
#mvn clean