Implemented latest image uploading

Change-Id: I43566fef691f0fa9ece94868f970236953edad75
diff --git a/Jenkinsfile b/Jenkinsfile
index c3b64e7..a92dbee 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -142,7 +142,14 @@
                             common.infoMsg("Uploading image " + imageName)
                             def uploadImageStatus = sh(script: "curl -f -T ${imageName} ${UPLOAD_URL}", returnStatus: true)
                             def uploadMd5Status = sh(script: "curl -f -T ${imageName}.md5 ${UPLOAD_URL}", returnStatus: true)
-
+                            // upload latest
+                            def latestImageName = imageName.substring(0, imageName.lastIndexOf("-")) + "-latest" + imageType
+                            common.infoMsg("Uploading image ${imageName} as latest")
+                            def uploadLatestStatus = sh(script: "curl -f -T ${imageName} ${UPLOAD_URL}${latestImageName}", returnStatus: true)
+                            def uploadLatestMd5Status = sh(script: "curl -f -T ${imageName}.md5 ${UPLOAD_URL}${latestImageName}.md5", returnStatus: true)
+                            if(uploadLatestStatus != 0 || uploadLatestMd5Status != 0){
+                                common.errorMsg("Latest image upload failed")
+                            }
                             if (GLANCE_UPLOAD == 'true' && glanceImgTypes.contains(imageType.substring(1))) {
                                 def glanceRunArgs = String.format("%s --disk-format %s --container-format bare", GLANCE_ARGS, imageType.substring(1))
                                 if (GLANCE_PUBLIC == 'true') {