deploy-schema.gradle 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. apply plugin: 'org.hidetake.ssh'
  2. project.ssh.settings {
  3. knownHosts = allowAnyHosts
  4. }
  5. project.remotes {
  6. docs {
  7. role 'docs'
  8. host = 'docs.af.pivotal.io'
  9. user = project.findProperty('deployDocsSshUsername')
  10. if(project.hasProperty('deployDocsSshKeyPath')) {
  11. identity = project.file(project.findProperty('deployDocsSshKeyPath'))
  12. }
  13. if(project.hasProperty('deployDocsSshPassphrase')) {
  14. passphrase = project.findProperty('deployDocsSshPassphrase')
  15. }
  16. }
  17. }
  18. project.task('deploySchema') {
  19. dependsOn 'schemaZip'
  20. doFirst {
  21. project.ssh.run {
  22. session(project.remotes.docs) {
  23. def now = System.currentTimeMillis()
  24. def name = project.rootProject.name
  25. def version = project.rootProject.version
  26. def tempPath = "/tmp/${name}-${now}-schema".replaceAll(' ', '_')
  27. execute "mkdir -p $tempPath"
  28. project.tasks.schemaZip.outputs.each { o ->
  29. println "Putting $o.files"
  30. put from: o.files, into: tempPath
  31. }
  32. execute "unzip $tempPath/*.zip -d $tempPath"
  33. def extractPath = "/var/www/domains/springsource.org/www/htdocs/autorepo/schema/${name}/${version}/"
  34. execute "rm -rf $extractPath"
  35. execute "mkdir -p $extractPath"
  36. execute "rm -f $tempPath*.zip"
  37. execute "rm -rf $extractPath*"
  38. execute "mv $tempPath/* $extractPath"
  39. }
  40. }
  41. }
  42. }