build.gradle 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. jar{
  2. enabled false
  3. }
  4. bootJar {
  5. enabled true
  6. }
  7. def releaseTime() {
  8. return new Date().format("yyyyMMdd", TimeZone.getTimeZone("GMT+08:00"))
  9. }
  10. archivesBaseName = "smartcity-zuul-${releaseTime()}"
  11. dependencies {
  12. implementation 'org.springframework.boot:spring-boot-starter-web'
  13. //implementation 'org.springframework.cloud:spring-cloud-starter-netflix-hystrix'
  14. //implementation 'org.springframework.cloud:spring-cloud-starter-netflix-eureka-client'
  15. implementation 'org.springframework.cloud:spring-cloud-starter-netflix-zuul'
  16. //implementation 'org.springframework.cloud:spring-cloud-starter-openfeign'
  17. implementation 'org.springframework.cloud:spring-cloud-starter-oauth2'
  18. implementation 'org.springframework.cloud:spring-cloud-starter-security'
  19. implementation 'com.alibaba.cloud:spring-cloud-starter-alibaba-nacos-discovery'
  20. }
  21. test {
  22. useJUnitPlatform()
  23. }
  24. task deploySit(dependsOn:bootJar){
  25. def active = 'sit'
  26. def applicationName = 'smartcity-zuul'
  27. def targetDir = '/opt/sit/smartcity-zuul'
  28. doLast {
  29. println "deploy ${applicationName} ${active}..."
  30. ssh.settings {
  31. knownHosts = allowAnyHosts
  32. }
  33. ssh.run {
  34. session(remotes.sitServer){
  35. put from: "build/libs/${jar.archiveName}", into: "${targetDir}"
  36. execute """
  37. source /root/.bash_profile;
  38. kill `ps aux | grep -i ${applicationName} | grep -v grep | awk '{print \$2}'`;
  39. nohup java -jar ${targetDir}/${jar.archiveName} --spring.profiles.active=${active} >/dev/null &
  40. """
  41. }
  42. }
  43. }
  44. }
  45. task deployUat(dependsOn:bootJar){
  46. def active = 'uat'
  47. def applicationName = 'smartcity-zuul'
  48. def targetDir = '/opt/uat/smartcity-zuul'
  49. doLast {
  50. println "deploy ${applicationName} ${active}..."
  51. ssh.settings {
  52. knownHosts = allowAnyHosts
  53. }
  54. ssh.run {
  55. session(remotes.uatServer155){
  56. put from: "build/libs/${jar.archiveName}", into: "${targetDir}"
  57. execute """
  58. source /root/.bash_profile;
  59. kill `ps aux | grep -i ${applicationName} | grep -v grep | awk '{print \$2}'`;
  60. nohup java -jar ${targetDir}/${jar.archiveName} --spring.profiles.active=${active} >/dev/null &
  61. """
  62. }
  63. }
  64. }
  65. }