diff --git a/Jenkinsfile b/Jenkinsfile
index a26d60e..3803e61 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -1,7 +1,7 @@
 import java.util.regex.Pattern
 /**
  *
- * Images build pipeline
+ * OS images build pipeline
  *
  * Expected parameters:
  *    BUILD_OS
@@ -18,18 +18,26 @@
  *    PIPELINE_LIBS_URL
  *    PIPELINE_LIBS_BRANCH
  *    PIPELINE_LIBS_CREDENTIALS_ID
+ *    GLANCE_UPLOAD
+ *    GLANCE_IMG_TYPES
+ *    GLANCE_URL
+ *    GLANCE_CREDENTIALS_ID
+ *    GLANCE_PROJECT
+ *    GLANCE_ARGS
+ *    OPENSTACK_API_CLIENT
  */
 
 // Load shared libs
-def common
-fileLoader.withGit(PIPELINE_LIBS_URL, PIPELINE_LIBS_BRANCH, PIPELINE_LIBS_CREDENTIALS_ID, '') {
-    common = fileLoader.load("common");
-}
+common = new com.mirantis.mk.Common()
 
 node('qemu') {
     // Define global variables
     def workspace = common.getWorkspace()
     def buildTypes = BUILD_ONLY.tokenize(" ")
+    def createdImages=[]
+    def uploadedImages=[]
+    def cleanedImages=[]
+
     checkout scm
     try {
         stage("prepare") {
@@ -50,6 +58,11 @@
                 sh "unzip ${PACKER_ZIP}"
             }
         }
+        // clean images dir before building
+        sh(script: String.format("rm -rf %s/images/*", BUILD_OS), returnStatus: true)
+        // clean virtualenv is exists
+        sh(script: String.format("rm -rf %s/venv", workspace), returnStatus: true)
+
         stage("build") {
             dir(BUILD_OS) {
                 withEnv([String.format("PATH=%s:%s/bin", env.PATH, workspace),
@@ -73,11 +86,13 @@
                             if (imageQemu != null && imageQemu != "") {
                                 def qemuConvertStatus = sh(script: "qemu-img convert -c -O qcow2 ${imageQemu} ${imageQemu}.qcow2", returnStatus:true)
                                 if(qemuConvertStatus == 0){
-                                    def imageDir = imageQemu.substring(0, imageQemu.lastIndexOf("/") + 1);
+                                    def imageDir = imageQemu.substring(0, imageQemu.lastIndexOf("/") + 1)
+                                    def imageQemuName = imageQemu.substring(imageQemu.lastIndexOf("/") + 1)
                                     def moveResult = sh(script: "mv ${imageQemu}.qcow2  ${imageDir}..", returnStatus: true)
                                     if(moveResult == 0){
                                         sh "rm -rf ${imageDir}"
                                         sh "rm -f ${imageQemu}"
+                                        createdImages.add(imageQemuName+".qcow2")
                                     }
                                 }else{
                                     throw new Exception("Qemu image convert failed")
@@ -90,6 +105,7 @@
                                 def pbZip2Status = sh(script: "pbzip2 ${imageDocker}", returnStatus: true)
                                 if(pbZip2Status == 0){
                                     sh "rm -f ${imageDocker}"
+                                    createdImages.add(imageDocker+".bz2")
                                 }else{
                                     throw new Exception("pbzip2 image convert failed")
                                 }
@@ -104,9 +120,14 @@
         stage("upload"){
             dir(BUILD_OS + "/images") {
                 def images = findFiles(glob: "*.*")
-                def uploadedImages=[]
-                def cleanedImages=[]
                 def imageBuilds = [:]
+                def openstack = new com.mirantis.mk.Openstack()
+                def openstackEnv = String.format("%s/venv", workspace);
+                def openstackVersion = OPENSTACK_API_CLIENT ? OPENSTACK_API_CLIENT : 'liberty'
+                def rcFile = openstack.createOpenstackEnv(GLANCE_URL, GLANCE_CREDENTIALS_ID, GLANCE_PROJECT)
+                def glanceImgTypes = GLANCE_IMG_TYPES.tokenize(" ")
+                openstack.setupOpenstackVirtualenv(openstackEnv, openstackVersion)
+                openstack.runOpenstackCommand("pip install python-glanceclient==1.0.0", rcFile, openstackEnv)
                 for (int i = 0; i < images.size(); i++) {
                     def imageName = images[i].name
                     def imageNameList = imageName.tokenize(".")
@@ -114,15 +135,27 @@
                     if(imageType.equals(".md5")){
                         continue;
                     }
+
                     imageBuilds["build${i}"]={
                         if (SKIP_UPLOAD != 'true') {
                             sh "md5sum ${imageName} > ${imageName}.md5"
                             println("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)
+
+                            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') {
+                                    glanceRunArgs += " --visibility public"
+                                }
+
+                                def imageShortName = imageNameList.get(0)
+                                openstack.runOpenstackCommand(String.format("glance image-create --name '%s' %s --file %s", imageShortName, glanceRunArgs, imageName), rcFile, openstackEnv)
+                            }
                             if(uploadImageStatus==0 && uploadMd5Status == 0){
                                 uploadedImages.add(imageName)
                                 sh(String.format("rm -r %s %s.md5",imageName, imageName))
+                                createdImages.remove(imageName)
                             }else{
                                 throw new Exception("Image upload failed")
                             }
@@ -160,6 +193,14 @@
                 sh "docker rmi --force \$(grep \"docker: Image ID:\" ${PACKER_LOG_PATH} | cut -d : -f 6 | head -1 | sed s,\\ ,,g) || true"
             }
         }
+        // clean created images if error occured
+        if(!createdImages.isEmpty()){
+            dir(BUILD_OS + "/images"){
+                for(int i=0;i<createdImages.size();i++){
+                    sh String.format("rm -f %s",createdImages.get(i))
+                }
+            }
+        }
     }
 }
 
