pipeline { agent any stages { stage('checkout 代码') { steps { git branch: 'sync-data', credentialsId: 'fly_gitlab_auth', url: 'http://172.24.16.20/root/fly_moon_crawlspider.git' } } stage('Maven 编译') { steps { sh "cd ${WORKSPACE}/ && mvn clean install -Dmaven.test.skip=true" } } stage('jar 下线') { steps { sh "ssh 172.24.16.10 'sh /data/sh/kill_fly_moon_crawlSpider-syncData.sh' " } } stage('jar 同步') { steps { sh """ scp ${WORKSPACE}/target/fly_moon_crawlSpider-0.0.1-SNAPSHOT.jar 172.24.16.10:/data/webapps/syncData/fly_moon_crawlSpider-0.0.1-SNAPSHOT.jar """ } } stage('jar 启动') { steps { sh "ssh 172.24.16.10 'nohup /data/jdk1.8.0_181/bin/java -jar /data/webapps/syncData/fly_moon_crawlSpider-0.0.1-SNAPSHOT.jar >/data/webapps/syncData/nohup-0.0.1.out 2>&1 &' " } } } } kill_fly_moon_crawlSpider-syncData.sh ps axjf|grep fly_moon_crawlSpider-0.0.1-SNAPSHOT|grep -v grep |awk '{print "kill ",$2}'|sh -