Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Implement and employ less verbose version of HashWriteProgress on dep…

…loy.
  • Loading branch information...
commit 918db129a0eb31c4dd67e0ae27776adfb10b2da3 1 parent 94c3f37
Marco Vermeulen authored
View
5 scripts/BeesAppDeploy.groovy
@@ -1,5 +1,4 @@
import grails.util.Metadata
-import com.cloudbees.api.HashWriteProgress
includeTargets << grailsScript("Init")
includeTargets << new File("${cloudBeesPluginDir}/scripts/_CheckConfig.groovy")
@@ -14,7 +13,7 @@ grails bees-app-deploy [appId] [tag]
target(beesAppDeploy: "Deploy a new version of an application using a WAR archive file.") {
depends(checkConfig, prepareClient)
-
+
String appId = buildAppId()
String tag = buildAppTag()
@@ -36,7 +35,7 @@ target(beesAppDeploy: "Deploy a new version of an application using a WAR archiv
}
def response
- def progress = new HashWriteProgress()
+ def progress = classLoader.loadClass("org.grails.plugins.cloudbees.HashWriteProgress", true).newInstance()
try {
event "StatusFinal", ["Deploying $appId tagged at version $tag"]
response = beesClient.applicationDeployArchive(appId, null, tag, warName, null, "war", true, parameters, progress)
View
30 src/groovy/org/grails/plugins/cloudbees/HashWriteProgress.groovy
@@ -0,0 +1,30 @@
+package org.grails.plugins.cloudbees
+
+import com.cloudbees.api.UploadProgress
+
+class HashWriteProgress implements UploadProgress {
+ def uploadComplete = false
+ def hashMarkCount = 0
+
+ void handleBytesWritten(long deltaCount, long totalWritten, long totalToSend) {
+
+ if(uploadComplete) return
+
+ int totalMarks = (int)(totalWritten/(totalToSend/100f))
+
+ while(hashMarkCount < totalMarks) {
+ hashMarkCount++
+ if(hashMarkCount % 25 == 0) {
+ if(hashMarkCount < 100) {
+ println String.format("uploaded %d%%", hashMarkCount)
+ } else {
+ //upload completed (or will very soon)
+ uploadComplete = true
+ println "upload completed"
+ println "deploying application to server(s)..."
+ }
+ }
+ }
+ }
+
+}
Please sign in to comment.
Something went wrong with that request. Please try again.