java

step 1 打包

Maven

  1. clean package -DskipTests -Dmaven.javadoc.skip=true

step 2 上传jar到服务器

SSH Upload

  1. # root 用户上传会上传到 /root/test ,其他用户会上传到 /home/其他/test
  2. %teamcity.build.workingDir%/target/jar => /test

step 3 运行jar

SSH Exec

  1. # 1. 移动上传上来的jar 到指定的目录去
  2. mv /root/test/imicams-kdp-1.0-SNAPSHOT.jar /home/detabes/softwares/imicams/java/
  3. # 2. 进入指定的目录
  4. cd /home/detabes/softwares/imicams/java/
  5. # 3. 将jar备个份
  6. cp imicams-kdp-1.0-SNAPSHOT.jar imicams-kdp-1.0-SNAPSHOT.jar-%build.number%
  7. # 4. 启动前先 kill
  8. kill -9 $(ps -ef|grep imicams-kdp-1.0-SNAPSHOT.jar|gawk '$0 !~/grep/ {print $2}' |tr -s '\n' ' ')
  9. # 5. 启动jar
  10. nohup java -jar -Xms512m -Xmx1024m -Xmn1024m -XX:+UseParallelGC -XX:+UseParallelOldGC imicams-kdp-1.0-SNAPSHOT.jar --server.port=9006 --spring.profiles.active=183 >/dev/null 2>&1 &

vue

step 1 npm install

Command Line (windows)

  1. npm install --registry=https://registry.npm.taobao.org

step 2 npm run build

Command Line

  1. npm run build

step 3 上传管理端页面到服务器

SSH Upload

  1. # # root 用户上传会上传到 /root/test/imicams/dist/ ,其他用户会上传到 /home/其他/test/imicams/dist/
  2. %teamcity.build.workingDir%/dist/** => /test/imicams/dist/

step 4 移动到指定目录

SSH Exec

  1. # 1. 移动上传上来的html 到指定的目录去
  2. cp -rf /home/cwwa//test/lib/dist/** /home/cwwa/nginx/html/lib/dist/
  3. # 2, 备个份
  4. cp -r /home/cwwa/nginx/html/lib/ /home/cwwa/nginx/html/lib-%teamcity.build.id%
  5. # 3. 给nginx目录一个权限(可选
  6. chmod -R 777 /home/cwwa/nginx/

JAVA Docker

step 1 打包

Maven

  1. clean package -DskipTests -Dmaven.javadoc.skip=true

step 2 docker 打包

构建镜像(maven打包时会构建) ,随意此处可以忽略 image.png

step 3 上传阿里云私服

PowerShell

  1. # 登录私服 在命令端登录没有用,必须在这儿登录
  2. docker login --username=账户 --password=密码 registry.cn-hangzhou.aliyuncs.com
  3. # 开始上传
  4. docker tag detabes/resource_library:latest registry.cn-hangzhou.aliyuncs.com/detabes/resource_library:latest
  5. docker tag detabes/resource_library:latest registry.cn-hangzhou.aliyuncs.com/detabes/resource_library:%build.number%-teamcity
  6. docker push registry.cn-hangzhou.aliyuncs.com/detabes/resource_library:latest
  7. docker push registry.cn-hangzhou.aliyuncs.com/detabes/resource_library:%build.number%-teamcity

step 4 启动项目

SSH Exec

  1. cd /home/cwwa
  2. echo "sudo时可能会出现输入密码这里就时填的密码" | sudo -S docker stop library
  3. echo "sudo时可能会出现输入密码这里就时填的密码" | sudo -S docker rm library
  4. echo "sudo时可能会出现输入密码这里就时填的密码" | sudo -S docker rmi $(docker images -q --filter reference=registry.cn-hangzhou.aliyuncs.com/detabes/resource_library:latest)
  5. # # 登录私服 在命令端登录没有用,必须在这儿登录
  6. echo "sudo时可能会出现输入密码这里就时填的密码" | sudo -S docker login --username=账户 --password=密码 registry.cn-hangzhou.aliyuncs.com
  7. echo "sudo时可能会出现输入密码这里就时填的密码" | sudo -S docker-compose -f docker-compose-jar.yml -p library up -d