4x/iot-user-center-standard-ba.../Jenkinsfile

47 lines
1.7 KiB
Groovy

pipeline {
agent any
environment {
LOB_NAME = 'water'
MODULE_NAME = 'iot-user-center'
A_HOSTS = 'water_machine'
}
stages {
stage('Show Branch and Hosts') {
steps {
echo "Branch is :${branch}"
}
}
stage('pull git') {
steps {
git (url:'git@192.168.9.222:ff-iot-cloud/iot-user-center.git',changelog: true,poll:true)
sh 'git reset --hard ${branch}'
echo 'pull codes'
}
}
stage('maven branch') {
steps {
sh '''export JAVA_HOME=/opt/app/jdk1.8.0_351/
export PATH=$PATH:/opt/app/maven-3.8.6/bin
mvn -f ${WORKSPACE}/pom.xml -U clean package -P test -Dmaven.test.skip=true
rsync -avP ${WORKSPACE}/${MODULE_NAME}-main/target/*.war /home/apple/ansible/water/war/${LOB_NAME}/${MODULE_NAME}/${MODULE_NAME}.war
if [ "${save}" = "yes" ]; then
cp -r /home/apple/ansible/water/war/${LOB_NAME}/${MODULE_NAME}/${MODULE_NAME}.war /home/apple/ansible/water/war/${LOB_NAME}/${MODULE_NAME}/bak/${MODULE_NAME}.war-`date +%Y%m%d%H%M`
fi
'''
echo 'pull codes'
}
}
stage('Deploy to Hosts') {
steps {
wrap([$class: 'BuildUser']) {
sh '''
ansible-playbook /home/apple/ansible/water/war-common.yml -e "module_name=${MODULE_NAME} lob_name=${LOB_NAME} group=${Hosts}"
'''
}
}
}
}
}