def checkinVersionFiles(self): tfscheckincomment = "SetVersion script: Updated IC version.cs to " + self.newversion ibslib.tfsCheckin(self.options.versioncsfile, tfscheckincomment, self.options.tfs_user, self.options.tfs_pass) # For Telenor builds only, check in config files if self.options.projectroot.__contains__('THOR'): tfscheckincomment = "SetVersion script: Updated Telenor " + self.configfile.split("\\")[len(self.configfile.split("\\"))-1] + " to " + self.newversion ibslib.tfsCheckin(self.configfile, tfscheckincomment, self.options.tfs_user, self.options.tfs_pass)
def checkInScripts(self): if self.options.verbose: print("\nrunning checkInScripts() function") print("tfs_user="******"tfs_pass="******"CreateAll script: Upgrade scripts approved and new create all scripts generated" for schema in self.schemas: # Add new scripts if needed to TFS ibslib.tfsAdd(self.options.base_path + "\\" + schema + "\\*.sql", self.options.tfs_user, self.options.tfs_pass) # Check in scripts ibslib.tfsCheckin(self.options.base_path + "\\*.sql", tfscheckincomment, self.options.tfs_user, self.options.tfs_pass) ibslib.tfsCheckin(self.options.base_path + "\\*.approved", tfscheckincomment, self.options.tfs_user, self.options.tfs_pass)
def updateICMain(self): schemas = ["CI_CENTRAL", "CI_QUEUEDATA"] # 1. tfs get latest of client\IC Main Scripts ibslib.tfsGet(self.options.clientroot + "\\IC Main Scripts", self.options.tfs_user, self.options.tfs_pass) # 2. tfs get latest of main\builds\yyyy\<version>\IC Main DLL ibslib.tfsGet(self.options.icmainroot + "\\builds\\" + str(datetime.date.today().year) + "\\" + self.options.icmainversion + "\\IC Main DLL", self.options.tfs_user, self.options.tfs_pass) # 3. tfs get latest of main\integration\CreateCI_DB ibslib.tfsGet(self.options.icmainroot + "\\integration\\CreateCI_DB", self.options.tfs_user, self.options.tfs_pass) # 4. tfs delete each folder in client\IC Main Scripts\<SCHEMA> for schema in schemas: # perform tfs undo of any pending checkins ibslib.tfsUndo(self.options.clientroot + "\\IC Main Scripts\\" + schema, self.options.tfs_user, self.options.tfs_pass) # perform tfs delete of any subfolders remaining for folder in glob.glob(self.options.clientroot + "\\IC Main Scripts\\" + schema + "\\*"): ibslib.tfsDelete(folder, self.options.tfs_user, self.options.tfs_pass) # delete all left over files, if any exist if os.path.exists(folder): ibslib.unsetReadOnly(folder) rmtree(folder) # 5. tfs recursive checkout client\IC Main DLL\* ibslib.tfsCheckout(self.options.clientroot + "\\IC Main DLL\\*", self.options.tfs_user, self.options.tfs_pass) # ensure remaining files are writable ibslib.unsetReadOnly(self.options.clientroot + "\\IC Main DLL") # 6. recursive copy main\builds\yyyy\<version>\IC Main DLL\* to client\IC Main DLL ibslib.copyFiles(self.options.icmainroot + "\\builds\\" + str(datetime.date.today().year) + "\\" + self.options.icmainversion + "\\IC Main DLL\\*", self.options.clientroot + "\\IC Main DLL\\") # 7. recursive copy main\integration\CreateCI_DB\<SCHEMA>\UpdateScripts\<version> to client\IC Main Scripts\<SCHEMA> paddedversion = self.options.icmainversion.split(".")[0].rjust(2, "0") + "." + self.options.icmainversion.split(".")[1].rjust(2, "0") + "." + self.options.icmainversion.split(".")[2].rjust(2, "0") + "." + self.options.icmainversion.split(".")[3].rjust(2, "0") for schema in schemas: copytree(self.options.icmainroot + "\\integration\\CreateCI_DB\\" + schema + "\\UpdateScripts\\" + paddedversion, self.options.clientroot + "\\IC Main Scripts\\" + schema + "\\" + paddedversion) # 8. tfs add client\IC Main Scripts\<SCHEMA>\<version> ibslib.tfsAdd(self.options.clientroot + "\\IC Main Scripts\\" + schema + "\\" + paddedversion, self.options.tfs_user, self.options.tfs_pass) # 9. tfs checkin client projectname = self.options.clientroot.split("\\")[self.options.clientroot.split("\\").__len__() - 2] tfscheckincomment = "UpdateClientICMain script: Incremented " + projectname + " IC Main version to " + self.options.icmainversion ibslib.tfsCheckin(self.options.clientroot, tfscheckincomment, self.options.tfs_user, self.options.tfs_pass)
def createVersionedDbScripts(self): if self.options.verbose: print("\nrunning createVersionedDbScripts() function") print("tfs_user="******"tfs_pass="******"base_path=", self.options.base_path) print("new_db_version=", self.options.new_db_version) ibslib.makeDir(self.options.base_path + "\\..\\Setup\\DbUpgrade\\DBScripts\\" + self.options.new_db_version) for schema in self.schemas: targetschema = schema if schema == "QD": targetschema = "CI_QUEUEDATA" # Create versioned schema folders for today's build ibslib.makeDir(self.options.base_path + "\\..\\Setup\\DbUpgrade\\DBScripts\\" + self.options.new_db_version + "\\" + targetschema) # Copy approved SQL scripts into today's build folders ibslib.copyFiles(self.options.base_path + "\\" + schema + "\\UpdateScripts\\Approved\\*.approved", self.options.base_path + "\\..\\Setup\\DbUpgrade\\DBScripts\\" + self.options.new_db_version + "\\" + targetschema + "\\") # Rename .Approved to .SQL ibslib.moveFiles(self.options.base_path + "\\..\\Setup\\DbUpgrade\\DBScripts\\" + self.options.new_db_version + "\\" + targetschema + "\\*.approved", self.options.base_path + "\\..\Setup\\DbUpgrade\\DBScripts\\" + self.options.new_db_version + "\\" + targetschema + "\\*.SQL") # Make sure at least one .SQL file exists for each schema if len(glob.glob(self.options.base_path + "\\..\\Setup\\DbUpgrade\\DBScripts\\" + self.options.new_db_version + "\\" + targetschema + "\\*.sql")) == 0: fi = open(self.options.base_path + "\\..\\Setup\\DbUpgrade\\DBScripts\\" + self.options.new_db_version + "\\" + targetschema + "\\blank.sql", "w") fi.close() # TFS Add Files to installer area ibslib.tfsAdd(self.options.base_path + "\\..\\Setup\\DbUpgrade\\DBScripts\\" + self.options.new_db_version + "\\*.sql", self.options.tfs_user, self.options.tfs_pass) ibslib.tfsCheckin(self.options.base_path + "\\..\Setup\\DbUpgrade\\DBScripts\\" + self.options.new_db_version + "\\*.sql", "CreateAll script: Checking in moved scripts", self.options.tfs_user, self.options.tfs_pass) for schema in self.schemas: # Remove old SQL files from TFS ibslib.tfsDelete(self.options.base_path + "\\" + schema + "\\UpdateScripts\\Approved\\*.approved", self.options.tfs_user, self.options.tfs_pass) ibslib.tfsCheckin(self.options.base_path + "\\" + schema + "\\UpdateScripts\\Approved", "CreateAll script: Deleting old approved scripts", self.options.tfs_user, self.options.tfs_pass)
def checkinVersionFiles(self): tfscheckincomment = "IncrementVersion script: Incremented " + self.projectname + " IC version to " + self.newversion ibslib.tfsCheckin(self.options.versionxmlfile, tfscheckincomment, self.options.tfs_user, self.options.tfs_pass) tfscheckincomment = "IncrementVersion script: Updated " + self.projectname + " IC version.cs to " + self.newversion ibslib.tfsCheckin(self.options.versioncsfile, tfscheckincomment, self.options.tfs_user, self.options.tfs_pass) # For Telenor builds only, check in config files if self.options.versionxmlfile.__contains__('Telenor'): tfscheckincomment = "IncrementVersion script: Updated " + self.projectname + " " + self.configfile.split("\\")[len(self.configfile.split("\\"))-1] + " to " + self.newversion ibslib.tfsCheckin(self.configfile, tfscheckincomment, self.options.tfs_user, self.options.tfs_pass)
def createBranch(self): if os.path.exists(self.options.versionxmlfile): tree = ElementTree(file=self.options.versionxmlfile) LastVersionNode = tree.find(".//LastVersion") if LastVersionNode == None: print("LastVersion element not found in version XML file!") exit(1) lastVersionText = "".join(LastVersionNode.itertext()) LabelNode = tree.find(".//Label") if LabelNode == None: print("Label element not found in version XML file!") exit(1) labelText = "".join(LabelNode.itertext()) labelText = labelText.replace("${LastVersion}", lastVersionText) TargetBranchNode = tree.find(".//TargetTFSBranchPath") if TargetBranchNode == None: print( "Target TFS branch path element not found in version XML file!" ) exit(1) targetBranchText = "".join(TargetBranchNode.itertext()) targetBranchText = targetBranchText.replace( "${LastVersion}", lastVersionText) targetBranchText = targetBranchText.replace( "${Year}", str(datetime.date.today().year)) ServerBranchNode = tree.find(".//LocalBranchPath") if ServerBranchNode == None: print( "Local branch path element not found in version XML file!") exit(1) serverBranchText = "".join(ServerBranchNode.itertext()) serverBranchText = serverBranchText.replace( "${LastVersion}", lastVersionText) serverBranchText = serverBranchText.replace( "${Year}", str(datetime.date.today().year)) serverBranchText = serverBranchText.replace( "${Integration_Root}", self.options.integrationroot) IsICMainNode = tree.find(".//IsICMainBuild") if IsICMainNode == None: print("IsICMainBuild element not found in version XML file!") exit(1) isICMainBuild = bool(int("".join(IsICMainNode.itertext()))) BuildsFolderNode = tree.find(".//BuildsFolder") if BuildsFolderNode == None: print("BuildsFolder element not found in version XML file!") exit(1) buildsFolderText = "".join(BuildsFolderNode.itertext()) buildsFolderText = buildsFolderText.replace( "${Integration_Root}", self.options.integrationroot) tfscheckincomment = "CreateBranch script: Creating branch from label '" + labelText + "'" # Decloak build folders for folder in ibslib.tfsDir(buildsFolderText, self.options.tfs_user, self.options.tfs_pass): ibslib.tfsDecloak( buildsFolderText + "\\" + folder.split("$")[1], self.options.tfs_user, self.options.tfs_pass) if isICMainBuild: # Generate full padded IC main version string icmainversion = lastVersionText.split(".")[0].rjust( 2, "0") + "." + lastVersionText.split(".")[1].rjust( 2, "0") + "." + lastVersionText.split(".")[2].rjust( 2, "0") + "." + lastVersionText.split(".")[3].rjust( 2, "0") # Actually create the branch ibslib.tfsBranch(labelText, self.options.projectroot, targetBranchText, True, self.options.tfs_user, self.options.tfs_pass) # Create the IC Main DLL folders ibslib.makeDir(serverBranchText) ibslib.makeDir(serverBranchText + "\\IC Main DLL") ibslib.makeDir(serverBranchText + "\\IC Main DLL\\Schemas") ibslib.makeDir(serverBranchText + "\\IC Main DLL\\es") ibslib.makeDir(serverBranchText + "\\IC Main DLL\\Oracle DLL") ibslib.makeDir(serverBranchText + "\\IC Main DLL\\Templates") ibslib.makeDir(serverBranchText + "\\IC Main DLL\\Transformers") ibslib.makeDir( serverBranchText + "\\IC Main DLL\\Transformers\\ConditionalAccess") ibslib.makeDir( serverBranchText + "\\IC Main DLL\\Transformers\\ConditionalAccess\\Common") ibslib.makeDir( serverBranchText + "\\IC Main DLL\\Transformers\\ConditionalAccess\\Nagra") ibslib.makeDir( serverBranchText + "\\IC Main DLL\\Transformers\\ConditionalAccess\\Nagra\\Aladin.1.4" ) ibslib.makeDir( serverBranchText + "\\IC Main DLL\\Transformers\\ConditionalAccess\\Nagra\\Common" ) ibslib.makeDir( serverBranchText + "\\IC Main DLL\\Transformers\\ConditionalAccess\\Nagra\\Merlin.2.1" ) ibslib.makeDir( serverBranchText + "\\IC Main DLL\\Transformers\\ConditionalAccess\\Control.6.14" ) ibslib.makeDir( serverBranchText + "\\IC Main DLL\\Transformers\\ConditionalAccess\\Control.6.14\\Common" ) # Copy the IC Main DLLs over ibslib.copyFiles( self.options.projectroot + "\\IC Main DLL\\*.*", serverBranchText + "\\IC Main DLL\\") ibslib.copyFiles( self.options.projectroot + "\\IC Main DLL\\Schemas\\*.*", serverBranchText + "\\IC Main DLL\\Schemas\\") ibslib.copyFiles( self.options.projectroot + "\\IC Main DLL\\es\\*.*", serverBranchText + "\\IC Main DLL\\es\\") ibslib.copyFiles( self.options.projectroot + "\\IC Main DLL\\Oracle DLL\\*.*", serverBranchText + "\\IC Main DLL\\Oracle DLL\\") ibslib.copyFiles( self.options.projectroot + "\\IC Main DLL\\Templates\\*.*", serverBranchText + "\\IC Main DLL\\Templates\\") ibslib.copyFiles( self.options.projectroot + "\\IC Main DLL\\Transformers\\*.*", serverBranchText + "\\IC Main DLL\\Transformers\\") ibslib.copyFiles( self.options.projectroot + "\\IC Main DLL\\Transformers\\ConditionalAccess\\*.*", serverBranchText + "\\IC Main DLL\\Transformers\\ConditionalAccess\\") ibslib.copyFiles( self.options.projectroot + "\\IC Main DLL\\Transformers\\ConditionalAccess\\Common\\*.*", serverBranchText + "\\IC Main DLL\\Transformers\\ConditionalAccess\\Common\\") ibslib.copyFiles( self.options.projectroot + "\\IC Main DLL\\Transformers\\ConditionalAccess\\Nagra\\Aladin.1.4\\*.*", serverBranchText + "\\IC Main DLL\\Transformers\\ConditionalAccess\\Nagra\\Aladin.1.4\\" ) ibslib.copyFiles( self.options.projectroot + "\\IC Main DLL\\Transformers\\ConditionalAccess\\Nagra\\Common\\*.*", serverBranchText + "\\IC Main DLL\\Transformers\\ConditionalAccess\\Nagra\\Common\\" ) ibslib.copyFiles( self.options.projectroot + "\\IC Main DLL\\Transformers\\ConditionalAccess\\Nagra\\Merlin.2.1\\*.*", serverBranchText + "\\IC Main DLL\\Transformers\\ConditionalAccess\\Nagra\\Merlin.2.1\\" ) ibslib.copyFiles( self.options.projectroot + "\\IC Main DLL\\Transformers\\ConditionalAccess\\Control.6.14\\*.*", serverBranchText + "\\IC Main DLL\\Transformers\\ConditionalAccess\\Control.6.14\\" ) ibslib.copyFiles( self.options.projectroot + "\\IC Main DLL\\Transformers\\ConditionalAccess\\Control.6.14\\Common\\*.*", serverBranchText + "\\IC Main DLL\\Transformers\\ConditionalAccess\\Control.6.14\\Common\\" ) # Create the IC Main Scripts folders ibslib.makeDir(serverBranchText + "\\IC Main Scripts") ibslib.makeDir(serverBranchText + "\\IC Main Scripts\\CI_CENTRAL") ibslib.makeDir(serverBranchText + "\\IC Main Scripts\\CI_CENTRAL\\" + icmainversion) ibslib.makeDir(serverBranchText + "\\IC Main Scripts\\CI_QUEUEDATA") ibslib.makeDir(serverBranchText + "\\IC Main Scripts\\CI_QUEUEDATA\\" + icmainversion) ibslib.makeDir(serverBranchText + "\\IC Main Scripts\\CI_BUSINESSDATA") ibslib.makeDir(serverBranchText + "\\IC Main Scripts\\CI_BUSINESSDATA\\" + icmainversion) # Move the DatabaseObjects folders ibslib.moveFiles( self.options.projectroot + "\\CreateCI_DB\\CI_CENTRAL\\UpdateScripts\\" + icmainversion + "\\DatabaseObjects", serverBranchText + "\\IC Main Scripts\\CI_CENTRAL\\" + icmainversion + "\\") ibslib.moveFiles( self.options.projectroot + "\\CreateCI_DB\\CI_QUEUEDATA\\UpdateScripts\\" + icmainversion + "\\DatabaseObjects", serverBranchText + "\\IC Main Scripts\\CI_QUEUEDATA\\" + icmainversion + "\\") ibslib.moveFiles( self.options.projectroot + "\\CreateCI_DB\\CI_BUSINESSDATA\\UpdateScripts\\" + icmainversion + "\\DatabaseObjects", serverBranchText + "\\IC Main Scripts\\CI_BUSINESSDATA\\" + icmainversion + "\\") # Copy ad-hoc scripts ibslib.copyFiles( self.options.projectroot + "\\CreateCI_DB\\CI_CENTRAL\\UpdateScripts\\*.*", serverBranchText + "\\IC Main Scripts\\CI_CENTRAL\\" + icmainversion) ibslib.copyFiles( self.options.projectroot + "\\CreateCI_DB\\CI_QUEUEDATA\\UpdateScripts\\*.*", serverBranchText + "\\IC Main Scripts\\CI_QUEUEDATA\\" + icmainversion) ibslib.copyFiles( self.options.projectroot + "\\CreateCI_DB\\CI_BUSINESSDATA\\UpdateScripts\\*.*", serverBranchText + "\\IC Main Scripts\\CI_BUSINESSDATA\\" + icmainversion) # Delete ad-hoc scripts from TFS ibslib.tfsDelete( self.options.projectroot + "\\CreateCI_DB\\CI_CENTRAL\\UpdateScripts\\*.*", self.options.tfs_user, self.options.tfs_pass) ibslib.tfsDelete( self.options.projectroot + "\\CreateCI_DB\\CI_QUEUEDATA\\UpdateScripts\\*.*", self.options.tfs_user, self.options.tfs_pass) ibslib.tfsDelete( self.options.projectroot + "\\CreateCI_DB\\CI_BUSINESSDATA\\UpdateScripts\\*.*", self.options.tfs_user, self.options.tfs_pass) # Delete intermediary files ibslib.delFiles(self.options.projectroot + "\\CreateCI_DB\\CI_CENTRAL\\UpdateScripts\\" + icmainversion) ibslib.delFiles( self.options.projectroot + "\\CreateCI_DB\\CI_QUEUEDATA\\UpdateScripts\\" + icmainversion) ibslib.delFiles( self.options.projectroot + "\\CreateCI_DB\\CI_BUSINESSDATA\\UpdateScripts\\" + icmainversion) # Add branch DLLs and scripts to TFS ibslib.tfsAdd(serverBranchText + "\\IC Main DLL", self.options.tfs_user, self.options.tfs_pass) ibslib.tfsAdd(serverBranchText + "\\IC Main Scripts", self.options.tfs_user, self.options.tfs_pass) # Check in files ibslib.tfsCheckin( self.options.projectroot + "\\CreateCI_DB", "CreateBranch script: Deleting IC Main update scripts", self.options.tfs_user, self.options.tfs_pass) else: ibslib.tfsBranch(labelText, self.options.projectroot, targetBranchText, False, self.options.tfs_user, self.options.tfs_pass) ibslib.tfsCheckin(serverBranchText, tfscheckincomment, self.options.tfs_user, self.options.tfs_pass) # Cloak builds folder for folder in ibslib.tfsDir(buildsFolderText, self.options.tfs_user, self.options.tfs_pass): ibslib.tfsCloak(buildsFolderText + "\\" + folder, self.options.tfs_user, self.options.tfs_pass) else: print("Version XML file not found!") exit(1)
def packageBuildICMain(self): self.targetpath = self.options.projectroot + "\\Setup\\Deploy" # Branch build steps if self.branchPath == None: # For branch builds, the branch path must be the same as the target path self.branchPath = self.options.projectroot # Create the IC Main Scripts folders ibslib.makeDir(self.branchPath + "\\IC Main Scripts") ibslib.makeDir(self.branchPath + "\\IC Main Scripts\\CI_CENTRAL") ibslib.makeDir(self.branchPath + "\\IC Main Scripts\\CI_CENTRAL\\" + self.newversion) ibslib.makeDir(self.branchPath + "\\IC Main Scripts\\CI_QUEUEDATA") ibslib.makeDir(self.branchPath + "\\IC Main Scripts\\CI_QUEUEDATA\\" + self.newversion) ibslib.makeDir(self.branchPath + "\\IC Main Scripts\\CI_BUSINESSDATA") ibslib.makeDir(self.branchPath + "\\IC Main Scripts\\CI_BUSINESSDATA\\" + self.newversion) # Move the DatabaseObjects folders ibslib.moveFiles( self.branchPath + "\\CreateCI_DB\\CI_CENTRAL\\UpdateScripts\\" + self.newversion + "\\DatabaseObjects", self.branchPath + "\\IC Main Scripts\\CI_CENTRAL\\" + self.newversion + "\\DatabaseObjects") ibslib.moveFiles( self.branchPath + "\\CreateCI_DB\\CI_QUEUEDATA\\UpdateScripts\\" + self.newversion + "\\DatabaseObjects", self.branchPath + "\\IC Main Scripts\\CI_QUEUEDATA\\" + self.newversion + "\\DatabaseObjects") ibslib.moveFiles( self.branchPath + "\\CreateCI_DB\\CI_BUSINESSDATA\\UpdateScripts\\" + self.newversion + "\\DatabaseObjects", self.branchPath + "\\IC Main Scripts\\CI_BUSINESSDATA\\" + self.newversion + "\\DatabaseObjects") # Copy ad-hoc scripts ibslib.copyFiles( self.branchPath + "\\CreateCI_DB\\CI_CENTRAL\\UpdateScripts\\*.*", self.branchPath + "\\IC Main Scripts\\CI_CENTRAL\\" + self.newversion) ibslib.copyFiles( self.branchPath + "\\CreateCI_DB\\CI_QUEUEDATA\\UpdateScripts\\*.*", self.branchPath + "\\IC Main Scripts\\CI_QUEUEDATA\\" + self.newversion) ibslib.copyFiles( self.branchPath + "\\CreateCI_DB\\CI_BUSINESSDATA\\UpdateScripts\\*.*", self.branchPath + "\\IC Main Scripts\\CI_BUSINESSDATA\\" + self.newversion) # Delete ad-hoc scripts from TFS ibslib.tfsDelete( self.branchPath + "\\CreateCI_DB\\CI_CENTRAL\\UpdateScripts\\*.*", self.options.tfs_user, self.options.tfs_pass) ibslib.tfsDelete( self.branchPath + "\\CreateCI_DB\\CI_QUEUEDATA\\UpdateScripts\\*.*", self.options.tfs_user, self.options.tfs_pass) ibslib.tfsDelete( self.branchPath + "\\CreateCI_DB\\CI_BUSINESSDATA\\UpdateScripts\\*.*", self.options.tfs_user, self.options.tfs_pass) # Delete intermediary files ibslib.delFiles(self.branchPath + "\\CreateCI_DB\\CI_CENTRAL\\UpdateScripts\\" + self.newversion) ibslib.delFiles(self.branchPath + "\\CreateCI_DB\\CI_QUEUEDATA\\UpdateScripts\\" + self.newversion) ibslib.delFiles(self.branchPath + "\\CreateCI_DB\\CI_BUSINESSDATA\\UpdateScripts\\" + self.newversion) # Add branch scripts to TFS ibslib.tfsAdd( self.branchPath + "\\IC Main Scripts\\CI_CENTRAL\\" + self.newversion, self.options.tfs_user, self.options.tfs_pass) ibslib.tfsAdd( self.branchPath + "\\IC Main Scripts\\CI_QUEUEDATA\\" + self.newversion, self.options.tfs_user, self.options.tfs_pass) ibslib.tfsAdd( self.branchPath + "\\IC Main Scripts\\CI_BUSINESSDATA\\" + self.newversion, self.options.tfs_user, self.options.tfs_pass) # Check in files ibslib.tfsCheckin( self.branchPath + "\\CreateCI_DB", "PackageBuildICMain script: Deleting IC Main update scripts", self.options.tfs_user, self.options.tfs_pass) ibslib.tfsCheckin( self.branchPath + "\\IC Main DLL", "PackageBuildICMain script: Updating IC Main DLLs", self.options.tfs_user, self.options.tfs_pass) ibslib.tfsCheckin( self.branchPath + "\\IC Main Scripts", "PackageBuildICMain script: Adding new IC Main DB Scripts", self.options.tfs_user, self.options.tfs_pass) self.zipfilenameDLL = self.branchPath + "\\IC Main " + self.newversion + " DLL.zip" self.zipfilenameDBScripts = self.branchPath + "\\IC Main " + self.newversion + " DBScripts.zip" # Create destination folders ibslib.makeDir(self.options.projectroot + "\\Setup") ibslib.makeDir(self.options.projectroot + "\\Setup\\Deploy") # Delete any previous zip files if they exist ibslib.delFiles(self.targetpath + "\\*.zip") ibslib.delFiles(self.branchPath + "\\*.zip") # Create DLL zip file buildzipfile = zipfile.ZipFile(self.zipfilenameDLL, "w") for name in ibslib.getFilesRecursive(self.branchPath + "\\IC Main DLL", "*.*"): relativepath = name.split("IC Main DLL\\")[1] print("Compressing - %s" % relativepath) buildzipfile.write(name, relativepath, zipfile.ZIP_DEFLATED) buildzipfile.close() # Create DBScripts zip file buildzipfile = zipfile.ZipFile(self.zipfilenameDBScripts, "w") for name in ibslib.getFilesRecursive( self.branchPath + "\\IC Main Scripts", "*.*"): relativepath = name.split("IC Main Scripts\\")[1] print("Compressing - %s" % relativepath) buildzipfile.write(name, relativepath, zipfile.ZIP_DEFLATED) buildzipfile.close() # Copy artifacts for TeamCity ibslib.copyFiles(self.branchPath + "\\*.zip", self.targetpath)
def createVersionedDbScripts(self): if self.options.verbose: print("\nrunning createVersionedDbScripts() function") print("tfs_user="******"tfs_pass="******"base_path=", self.options.base_path) self.schemas = self.options.schemalist.split(',') specialschemas = ["_PreProcess", "SMP", "zzPostProcess"] databaseobjectfolders = ["ForeignKeys", "Functions", "Packages", "Procedures", "Triggers", "Views", "Tables", "Sequences", "Types"] self.header = "/*-------------------------------------------------------------------------\n\ Version: ${Version}\n\ --------------------------------------------------------------------------*/" self.icmain_header = "/*-------------------------------------------------------------------------\n\ IC Main Version: ${Version}\n\ --------------------------------------------------------------------------*/" self.icmain_client_header = "/*-------------------------------------------------------------------------\n\ Client Version: ${Version}\n\ IC Main Version: ${ClientICMainVersion}\n\ --------------------------------------------------------------------------*/" self.viewcommentsql = "\n\nCOMMENT ON TABLE ${View} IS '" + self.header + "';\n/\n" self.tablecommentsql = "\n\nCOMMENT ON TABLE ${Table} IS '" + self.header + "${TableComment}';\n/\n" self.icmain_viewcommentsql = "\n\nCOMMENT ON TABLE ${View} IS '" + self.icmain_header + "';\n/\n" self.icmain_client_viewcommentsql = "\n\nCOMMENT ON TABLE ${View} IS '" + self.icmain_client_header + "';\n/\n" self.icmain_tablecommentsql = "\n\nCOMMENT ON TABLE ${Table} IS '" + self.icmain_header + "${TableComment}';\n/\n" self.icmain_client_tablecommentsql = "\n\nCOMMENT ON TABLE ${Table} IS '" + self.icmain_client_header + "${TableComment}';\n/\n" self.new_icmain_version = "" self.client_icmain_version = "" if self.options.is_icmain: self.new_icmain_version = self.new_db_version.split(".")[0].rjust(2, "0") + "." + self.new_db_version.split(".")[1].rjust(2, "0") + "." + self.new_db_version.split(".")[2].rjust(2, "0") + "." + self.new_db_version.split(".")[3].rjust(2, "0") else: ibslib.makeDir(self.options.base_path + "\\..\\Setup\\DbUpgrade\\DBScripts\\" + self.new_db_version) for specialschema in specialschemas: ibslib.makeDir(self.options.base_path + "\\..\\Setup\\DbUpgrade\\DBScripts\\" + specialschema) for schema in self.schemas: if self.options.is_icmain: # Create versioned schema folders for today's build if len(glob.glob(self.options.base_path + "\\" + schema + "\\UpdateScripts\\" + self.new_icmain_version)) == 0: ibslib.makeDir(self.options.base_path + "\\" + schema + "\\UpdateScripts\\" + self.new_icmain_version) if len(glob.glob(self.options.base_path + "\\" + schema + "\\UpdateScripts\\" + self.new_icmain_version + "\\DatabaseObjects")) == 0: ibslib.makeDir(self.options.base_path + "\\" + schema + "\\UpdateScripts\\" + self.new_icmain_version + "\\DatabaseObjects") for databaseobjectfolder in databaseobjectfolders: if len(glob.glob(self.options.base_path + "\\" + schema + "\\UpdateScripts\\" + self.new_icmain_version + "\\DatabaseObjects\\" + databaseobjectfolder)) == 0: ibslib.makeDir(self.options.base_path + "\\" + schema + "\\UpdateScripts\\" + self.new_icmain_version + "\\DatabaseObjects\\" + databaseobjectfolder) else: # Create versioned schema folders for today's build ibslib.makeDir(self.options.base_path + "\\..\\Setup\\DbUpgrade\\DBScripts\\" + self.new_db_version + "\\" + schema) for specialschema in specialschemas: ibslib.makeDir(self.options.base_path + "\\..\\Setup\\DbUpgrade\\DBScripts\\" + specialschema + "\\" + schema) # Copy approved SQL scripts into today's build folders ibslib.copyFiles(self.options.base_path + "\\" + schema + "\\UpdateScripts\\Approved\\*.approved", self.options.base_path + "\\..\\Setup\\DbUpgrade\\DBScripts\\" + self.new_db_version + "\\" + schema + "\\") for specialschema in specialschemas: ibslib.copyFiles(self.options.base_path + "\\" + schema + "\\Data\\" + specialschema + "\\Approved\\*.approved", self.options.base_path + "\\..\\Setup\\DbUpgrade\\DBScripts\\" + specialschema + "\\" + schema + "\\") # Rename .Approved to .SQL ibslib.moveFiles(self.options.base_path + "\\..\\Setup\\DbUpgrade\\DBScripts\\" + self.new_db_version + "\\" + schema + "\\*.approved", self.options.base_path + "\\..\Setup\\DbUpgrade\\DBScripts\\" + self.new_db_version + "\\" + schema + "\\*.SQL") for specialschema in specialschemas: ibslib.moveFiles(self.options.base_path + "\\..\\Setup\\DbUpgrade\\DBScripts\\" + specialschema + "\\" + schema + "\\*.approved", self.options.base_path + "\\..\Setup\\DbUpgrade\\DBScripts\\" + specialschema + "\\" + schema + "\\*.SQL") # Make sure at least one .SQL file exists for each schema if len(glob.glob(self.options.base_path + "\\..\\Setup\\DbUpgrade\\DBScripts\\" + self.new_db_version + "\\" + schema + "\\*.sql")) == 0: fi = open(self.options.base_path + "\\..\\Setup\\DbUpgrade\\DBScripts\\" + self.new_db_version + "\\" + schema + "\\blank.sql", "w") fi.close() for specialschema in specialschemas: if len(glob.glob(self.options.base_path + "\\..\\Setup\\DbUpgrade\\DBScripts\\" + specialschema + "\\" + schema + "\\*.sql")) == 0: fi = open(self.options.base_path + "\\..\\Setup\\DbUpgrade\\DBScripts\\" + specialschema + "\\" + schema + "\\blank.sql", "w") fi.close() # Copy database objects for databaseobjectfolder in databaseobjectfolders: # determine the dbscript folder dbscriptpath = self.options.base_path + "\\" + schema + "\\DatabaseObjects\\" + databaseobjectfolder # check out everything in the dbscript folder ibslib.tfsCheckout( dbscriptpath, self.options.tfs_user, self.options.tfs_pass) # Determine output folder if self.options.is_icmain: destscriptfolder = self.options.base_path + "\\" + schema + "\\UpdateScripts\\" + self.new_icmain_version + "\\DatabaseObjects\\" + databaseobjectfolder else: destscriptfolder = self.options.base_path + "\\..\\Setup\\DbUpgrade\\DBScripts\\_PreProcess\\" + schema # check out everything in the destination folder. ibslib.tfsCheckout( destscriptfolder, self.options.tfs_user, self.options.tfs_pass) for dbscript in glob.glob(dbscriptpath + "\\*.sql"): # Add comments to script tokens,values = self.addComments(dbscript, databaseobjectfolder) destscriptpath = destscriptfolder + "\\" + dbscript.rpartition("\\")[2] # Perform token replacement on script and copy to destination folder replaceresultsuccess = ibslib.replacetokens(tokens, values, dbscript, destscriptpath) if not replaceresultsuccess: print("Error running ReplaceTokens for database object '%s'." % dbscript) exit(1) # Undo original script (template) ibslib.tfsUndo(dbscriptpath, self.options.tfs_user, self.options.tfs_pass) if self.options.is_icmain_client: # Copy IC Main scripts to setup folder icmain_folders = glob.glob(self.options.base_path + "\\..\\IC Main Scripts\\" + schema + "\\*") if len(icmain_folders) > 0: for icmain_folder in icmain_folders: # Check out destination scripts if they exist tempDestPath = self.options.base_path + "\\..\\Setup\\DbUpgrade\\DBScripts\\" + self.new_db_version + "\\" + schema ibslib.tfsCheckout( tempDestPath, self.options.tfs_user, self.options.tfs_pass) ibslib.copyFiles(icmain_folder + "\\*.*", tempDestPath + "\\") # We need to get DatabaseObjects from most recent IC Main folder, # so sort the list to determine the most recent version. icmain_folder_versions = [] for icmain_folder in icmain_folders: icmain_folder_versions.append(icmain_folder.rpartition("\\")[2]) icmain_folder_versions = sorted(icmain_folder_versions, key=cmp_to_key(ibslib.compareVersions)) icmain_folder_versions.reverse() latest_icmain_folder = self.options.base_path + "\\..\\IC Main Scripts\\" + schema + "\\" + icmain_folder_versions[0] # Copy IC Main DB objects to setup folder for databaseobjectfolder in databaseobjectfolders: temp_latest_icmain_database_object_folder = latest_icmain_folder + "\\DatabaseObjects\\" + databaseobjectfolder # Check out script ibslib.tfsCheckout( temp_latest_icmain_database_object_folder, self.options.tfs_user, self.options.tfs_pass ) # Determine output path destscriptfolder = self.options.base_path + "\\..\\Setup\\DbUpgrade\\DBScripts\\_PreProcess\\" + schema # Check out destination scripts if it exists ibslib.tfsCheckout(destscriptfolder, self.options.tfs_user, self.options.tfs_pass) for dbscript in glob.glob(temp_latest_icmain_database_object_folder + "\\*.sql"): # Add comments to script tokens,values = self.addComments(dbscript, databaseobjectfolder) # Determine output path destscriptpath = destscriptfolder + "\\" + dbscript.rpartition("\\")[2] # Perform token replacement on script and copy to destination folder replaceresultsuccess = ibslib.replacetokens(tokens, values, dbscript, destscriptpath) # Undo original script (template) ibslib.tfsUndo(temp_latest_icmain_database_object_folder, self.options.tfs_user, self.options.tfs_pass) if not self.options.is_icmain: # TFS Add Files to installer area ibslib.tfsAdd(self.options.base_path + "\\..\\Setup\\DbUpgrade\\DBScripts\\" + self.new_db_version + "\\*.*", self.options.tfs_user, self.options.tfs_pass) for specialschema in specialschemas: for schema in self.schemas: ibslib.tfsAdd(self.options.base_path + "\\..\\Setup\\DbUpgrade\\DBScripts\\" + specialschema + "\\" + schema + "\\*.sql", self.options.tfs_user, self.options.tfs_pass) ibslib.tfsCheckin(self.options.base_path + "\\..\Setup\\DbUpgrade\\DBScripts\\*.*", "CreateAll script: Checking in moved scripts", self.options.tfs_user, self.options.tfs_pass) for schema in self.schemas: # Remove old SQL files from TFS ibslib.tfsDelete(self.options.base_path + "\\" + schema + "\\UpdateScripts\\Approved\\*.approved", self.options.tfs_user, self.options.tfs_pass) for specialschema in specialschemas: ibslib.tfsDelete(self.options.base_path + "\\" + schema + "\\Data\\" + specialschema + "\\Approved\\*.approved", self.options.tfs_user, self.options.tfs_pass) ibslib.tfsCheckin(self.options.base_path, "CreateAll script: Deleting old approved scripts", self.options.tfs_user, self.options.tfs_pass)
def createBranch(self): if os.path.exists(self.options.versionxmlfile): tree = ElementTree(file=self.options.versionxmlfile) LastVersionNode = tree.find(".//LastVersion") if LastVersionNode == None: print("LastVersion element not found in version XML file!") exit(1) lastVersionText = "".join(LastVersionNode.itertext()) LabelNode = tree.find(".//Label") if LabelNode == None: print("Label element not found in version XML file!") exit(1) labelText = "".join(LabelNode.itertext()) labelText = labelText.replace("${LastVersion}", lastVersionText) TargetBranchNode = tree.find(".//TargetTFSBranchPath") if TargetBranchNode == None: print("Target TFS branch path element not found in version XML file!") exit(1) targetBranchText = "".join(TargetBranchNode.itertext()) targetBranchText = targetBranchText.replace("${LastVersion}", lastVersionText) targetBranchText = targetBranchText.replace("${Year}", str(datetime.date.today().year)) ServerBranchNode = tree.find(".//LocalBranchPath") if ServerBranchNode == None: print("Local branch path element not found in version XML file!") exit(1) serverBranchText = "".join(ServerBranchNode.itertext()) serverBranchText = serverBranchText.replace("${LastVersion}", lastVersionText) serverBranchText = serverBranchText.replace("${Year}", str(datetime.date.today().year)) serverBranchText = serverBranchText.replace("${Integration_Root}", self.options.integrationroot) IsICMainNode = tree.find(".//IsICMainBuild") if IsICMainNode == None: print("IsICMainBuild element not found in version XML file!") exit(1) isICMainBuild = bool(int("".join(IsICMainNode.itertext()))) BuildsFolderNode = tree.find(".//BuildsFolder") if BuildsFolderNode == None: print("BuildsFolder element not found in version XML file!") exit(1) buildsFolderText = "".join(BuildsFolderNode.itertext()) buildsFolderText = buildsFolderText.replace("${Integration_Root}", self.options.integrationroot) tfscheckincomment = "CreateBranch script: Creating branch from label '" + labelText + "'" # Decloak build folders for folder in ibslib.tfsDir(buildsFolderText, self.options.tfs_user, self.options.tfs_pass): ibslib.tfsDecloak(buildsFolderText + "\\" + folder.split("$")[1], self.options.tfs_user, self.options.tfs_pass) if isICMainBuild: # Generate full padded IC main version string icmainversion = lastVersionText.split(".")[0].rjust(2, "0") + "." + lastVersionText.split(".")[1].rjust(2, "0") + "." + lastVersionText.split(".")[2].rjust(2, "0") + "." + lastVersionText.split(".")[3].rjust(2, "0") # Actually create the branch ibslib.tfsBranch(labelText, self.options.projectroot, targetBranchText, True, self.options.tfs_user, self.options.tfs_pass) # Create the IC Main DLL folders ibslib.makeDir(serverBranchText) ibslib.makeDir(serverBranchText + "\\IC Main DLL") ibslib.makeDir(serverBranchText + "\\IC Main DLL\\Schemas") ibslib.makeDir(serverBranchText + "\\IC Main DLL\\es") ibslib.makeDir(serverBranchText + "\\IC Main DLL\\Oracle DLL") ibslib.makeDir(serverBranchText + "\\IC Main DLL\\Templates") ibslib.makeDir(serverBranchText + "\\IC Main DLL\\Transformers") ibslib.makeDir(serverBranchText + "\\IC Main DLL\\Transformers\\ConditionalAccess") ibslib.makeDir(serverBranchText + "\\IC Main DLL\\Transformers\\ConditionalAccess\\Common") ibslib.makeDir(serverBranchText + "\\IC Main DLL\\Transformers\\ConditionalAccess\\Nagra") ibslib.makeDir(serverBranchText + "\\IC Main DLL\\Transformers\\ConditionalAccess\\Nagra\\Aladin.1.4") ibslib.makeDir(serverBranchText + "\\IC Main DLL\\Transformers\\ConditionalAccess\\Nagra\\Common") ibslib.makeDir(serverBranchText + "\\IC Main DLL\\Transformers\\ConditionalAccess\\Nagra\\Merlin.2.1") ibslib.makeDir(serverBranchText + "\\IC Main DLL\\Transformers\\ConditionalAccess\\Control.6.14") ibslib.makeDir(serverBranchText + "\\IC Main DLL\\Transformers\\ConditionalAccess\\Control.6.14\\Common") # Copy the IC Main DLLs over ibslib.copyFiles(self.options.projectroot + "\\IC Main DLL\\*.*", serverBranchText + "\\IC Main DLL\\") ibslib.copyFiles(self.options.projectroot + "\\IC Main DLL\\Schemas\\*.*", serverBranchText + "\\IC Main DLL\\Schemas\\") ibslib.copyFiles(self.options.projectroot + "\\IC Main DLL\\es\\*.*", serverBranchText + "\\IC Main DLL\\es\\") ibslib.copyFiles(self.options.projectroot + "\\IC Main DLL\\Oracle DLL\\*.*", serverBranchText + "\\IC Main DLL\\Oracle DLL\\") ibslib.copyFiles(self.options.projectroot + "\\IC Main DLL\\Templates\\*.*", serverBranchText + "\\IC Main DLL\\Templates\\") ibslib.copyFiles(self.options.projectroot + "\\IC Main DLL\\Transformers\\*.*", serverBranchText + "\\IC Main DLL\\Transformers\\") ibslib.copyFiles(self.options.projectroot + "\\IC Main DLL\\Transformers\\ConditionalAccess\\*.*", serverBranchText + "\\IC Main DLL\\Transformers\\ConditionalAccess\\") ibslib.copyFiles(self.options.projectroot + "\\IC Main DLL\\Transformers\\ConditionalAccess\\Common\\*.*", serverBranchText + "\\IC Main DLL\\Transformers\\ConditionalAccess\\Common\\") ibslib.copyFiles(self.options.projectroot + "\\IC Main DLL\\Transformers\\ConditionalAccess\\Nagra\\Aladin.1.4\\*.*", serverBranchText + "\\IC Main DLL\\Transformers\\ConditionalAccess\\Nagra\\Aladin.1.4\\") ibslib.copyFiles(self.options.projectroot + "\\IC Main DLL\\Transformers\\ConditionalAccess\\Nagra\\Common\\*.*", serverBranchText + "\\IC Main DLL\\Transformers\\ConditionalAccess\\Nagra\\Common\\") ibslib.copyFiles(self.options.projectroot + "\\IC Main DLL\\Transformers\\ConditionalAccess\\Nagra\\Merlin.2.1\\*.*", serverBranchText + "\\IC Main DLL\\Transformers\\ConditionalAccess\\Nagra\\Merlin.2.1\\") ibslib.copyFiles(self.options.projectroot + "\\IC Main DLL\\Transformers\\ConditionalAccess\\Control.6.14\\*.*", serverBranchText + "\\IC Main DLL\\Transformers\\ConditionalAccess\\Control.6.14\\") ibslib.copyFiles(self.options.projectroot + "\\IC Main DLL\\Transformers\\ConditionalAccess\\Control.6.14\\Common\\*.*", serverBranchText + "\\IC Main DLL\\Transformers\\ConditionalAccess\\Control.6.14\\Common\\") # Create the IC Main Scripts folders ibslib.makeDir(serverBranchText + "\\IC Main Scripts") ibslib.makeDir(serverBranchText + "\\IC Main Scripts\\CI_CENTRAL") ibslib.makeDir(serverBranchText + "\\IC Main Scripts\\CI_CENTRAL\\" + icmainversion) ibslib.makeDir(serverBranchText + "\\IC Main Scripts\\CI_QUEUEDATA") ibslib.makeDir(serverBranchText + "\\IC Main Scripts\\CI_QUEUEDATA\\" + icmainversion) ibslib.makeDir(serverBranchText + "\\IC Main Scripts\\CI_BUSINESSDATA") ibslib.makeDir(serverBranchText + "\\IC Main Scripts\\CI_BUSINESSDATA\\" + icmainversion) # Move the DatabaseObjects folders ibslib.moveFiles(self.options.projectroot + "\\CreateCI_DB\\CI_CENTRAL\\UpdateScripts\\" + icmainversion + "\\DatabaseObjects", serverBranchText + "\\IC Main Scripts\\CI_CENTRAL\\" + icmainversion + "\\") ibslib.moveFiles(self.options.projectroot + "\\CreateCI_DB\\CI_QUEUEDATA\\UpdateScripts\\" + icmainversion + "\\DatabaseObjects", serverBranchText + "\\IC Main Scripts\\CI_QUEUEDATA\\" + icmainversion + "\\") ibslib.moveFiles(self.options.projectroot + "\\CreateCI_DB\\CI_BUSINESSDATA\\UpdateScripts\\" + icmainversion + "\\DatabaseObjects", serverBranchText + "\\IC Main Scripts\\CI_BUSINESSDATA\\" + icmainversion + "\\") # Copy ad-hoc scripts ibslib.copyFiles(self.options.projectroot + "\\CreateCI_DB\\CI_CENTRAL\\UpdateScripts\\*.*", serverBranchText + "\\IC Main Scripts\\CI_CENTRAL\\" + icmainversion) ibslib.copyFiles(self.options.projectroot + "\\CreateCI_DB\\CI_QUEUEDATA\\UpdateScripts\\*.*", serverBranchText + "\\IC Main Scripts\\CI_QUEUEDATA\\" + icmainversion) ibslib.copyFiles(self.options.projectroot + "\\CreateCI_DB\\CI_BUSINESSDATA\\UpdateScripts\\*.*", serverBranchText + "\\IC Main Scripts\\CI_BUSINESSDATA\\" + icmainversion) # Delete ad-hoc scripts from TFS ibslib.tfsDelete(self.options.projectroot + "\\CreateCI_DB\\CI_CENTRAL\\UpdateScripts\\*.*", self.options.tfs_user, self.options.tfs_pass) ibslib.tfsDelete(self.options.projectroot + "\\CreateCI_DB\\CI_QUEUEDATA\\UpdateScripts\\*.*", self.options.tfs_user, self.options.tfs_pass) ibslib.tfsDelete(self.options.projectroot + "\\CreateCI_DB\\CI_BUSINESSDATA\\UpdateScripts\\*.*", self.options.tfs_user, self.options.tfs_pass) # Delete intermediary files ibslib.delFiles(self.options.projectroot + "\\CreateCI_DB\\CI_CENTRAL\\UpdateScripts\\" + icmainversion) ibslib.delFiles(self.options.projectroot + "\\CreateCI_DB\\CI_QUEUEDATA\\UpdateScripts\\" + icmainversion) ibslib.delFiles(self.options.projectroot + "\\CreateCI_DB\\CI_BUSINESSDATA\\UpdateScripts\\" + icmainversion) # Add branch DLLs and scripts to TFS ibslib.tfsAdd(serverBranchText + "\\IC Main DLL", self.options.tfs_user, self.options.tfs_pass) ibslib.tfsAdd(serverBranchText+ "\\IC Main Scripts", self.options.tfs_user, self.options.tfs_pass) # Check in files ibslib.tfsCheckin(self.options.projectroot + "\\CreateCI_DB", "CreateBranch script: Deleting IC Main update scripts", self.options.tfs_user, self.options.tfs_pass) else: ibslib.tfsBranch(labelText, self.options.projectroot, targetBranchText, False, self.options.tfs_user, self.options.tfs_pass) ibslib.tfsCheckin(serverBranchText, tfscheckincomment, self.options.tfs_user, self.options.tfs_pass) # Cloak builds folder for folder in ibslib.tfsDir(buildsFolderText, self.options.tfs_user, self.options.tfs_pass): ibslib.tfsCloak(buildsFolderText + "\\" + folder, self.options.tfs_user, self.options.tfs_pass) else: print("Version XML file not found!") exit(1)
def updateICMain(self): schemas = ["CI_CENTRAL", "CI_QUEUEDATA"] # 1. tfs get latest of client\IC Main Scripts ibslib.tfsGet(self.options.clientroot + "\\IC Main Scripts", self.options.tfs_user, self.options.tfs_pass) # 2. tfs get latest of main\builds\yyyy\<version>\IC Main DLL ibslib.tfsGet( self.options.icmainroot + "\\builds\\" + str(datetime.date.today().year) + "\\" + self.options.icmainversion + "\\IC Main DLL", self.options.tfs_user, self.options.tfs_pass) # 3. tfs get latest of main\integration\CreateCI_DB ibslib.tfsGet(self.options.icmainroot + "\\integration\\CreateCI_DB", self.options.tfs_user, self.options.tfs_pass) # 4. tfs delete each folder in client\IC Main Scripts\<SCHEMA> for schema in schemas: # perform tfs undo of any pending checkins ibslib.tfsUndo( self.options.clientroot + "\\IC Main Scripts\\" + schema, self.options.tfs_user, self.options.tfs_pass) # perform tfs delete of any subfolders remaining for folder in glob.glob(self.options.clientroot + "\\IC Main Scripts\\" + schema + "\\*"): ibslib.tfsDelete(folder, self.options.tfs_user, self.options.tfs_pass) # delete all left over files, if any exist if os.path.exists(folder): ibslib.unsetReadOnly(folder) rmtree(folder) # 5. tfs recursive checkout client\IC Main DLL\* ibslib.tfsCheckout(self.options.clientroot + "\\IC Main DLL\\*", self.options.tfs_user, self.options.tfs_pass) # ensure remaining files are writable ibslib.unsetReadOnly(self.options.clientroot + "\\IC Main DLL") # 6. recursive copy main\builds\yyyy\<version>\IC Main DLL\* to client\IC Main DLL ibslib.copyFiles( self.options.icmainroot + "\\builds\\" + str(datetime.date.today().year) + "\\" + self.options.icmainversion + "\\IC Main DLL\\*", self.options.clientroot + "\\IC Main DLL\\") # 7. recursive copy main\integration\CreateCI_DB\<SCHEMA>\UpdateScripts\<version> to client\IC Main Scripts\<SCHEMA> paddedversion = self.options.icmainversion.split(".")[0].rjust( 2, "0") + "." + self.options.icmainversion.split(".")[1].rjust( 2, "0") + "." + self.options.icmainversion.split(".")[2].rjust( 2, "0") + "." + self.options.icmainversion.split( ".")[3].rjust(2, "0") for schema in schemas: copytree( self.options.icmainroot + "\\integration\\CreateCI_DB\\" + schema + "\\UpdateScripts\\" + paddedversion, self.options.clientroot + "\\IC Main Scripts\\" + schema + "\\" + paddedversion) # 8. tfs add client\IC Main Scripts\<SCHEMA>\<version> ibslib.tfsAdd( self.options.clientroot + "\\IC Main Scripts\\" + schema + "\\" + paddedversion, self.options.tfs_user, self.options.tfs_pass) # 9. tfs checkin client projectname = self.options.clientroot.split("\\")[ self.options.clientroot.split("\\").__len__() - 2] tfscheckincomment = "UpdateClientICMain script: Incremented " + projectname + " IC Main version to " + self.options.icmainversion ibslib.tfsCheckin(self.options.clientroot, tfscheckincomment, self.options.tfs_user, self.options.tfs_pass)
def packageBuildICMain(self): self.targetpath = self.options.projectroot + "\\Setup\\Deploy" # Branch build steps if self.branchPath == None: # For branch builds, the branch path must be the same as the target path self.branchPath = self.options.projectroot # Create the IC Main Scripts folders ibslib.makeDir(self.branchPath + "\\IC Main Scripts") ibslib.makeDir(self.branchPath + "\\IC Main Scripts\\CI_CENTRAL") ibslib.makeDir(self.branchPath + "\\IC Main Scripts\\CI_CENTRAL\\" + self.newversion) ibslib.makeDir(self.branchPath + "\\IC Main Scripts\\CI_QUEUEDATA") ibslib.makeDir(self.branchPath + "\\IC Main Scripts\\CI_QUEUEDATA\\" + self.newversion) ibslib.makeDir(self.branchPath + "\\IC Main Scripts\\CI_BUSINESSDATA") ibslib.makeDir(self.branchPath + "\\IC Main Scripts\\CI_BUSINESSDATA\\" + self.newversion) # Move the DatabaseObjects folders ibslib.moveFiles(self.branchPath + "\\CreateCI_DB\\CI_CENTRAL\\UpdateScripts\\" + self.newversion + "\\DatabaseObjects", self.branchPath + "\\IC Main Scripts\\CI_CENTRAL\\" + self.newversion + "\\DatabaseObjects") ibslib.moveFiles(self.branchPath + "\\CreateCI_DB\\CI_QUEUEDATA\\UpdateScripts\\" + self.newversion + "\\DatabaseObjects", self.branchPath + "\\IC Main Scripts\\CI_QUEUEDATA\\" + self.newversion + "\\DatabaseObjects") ibslib.moveFiles(self.branchPath + "\\CreateCI_DB\\CI_BUSINESSDATA\\UpdateScripts\\" + self.newversion + "\\DatabaseObjects", self.branchPath + "\\IC Main Scripts\\CI_BUSINESSDATA\\" + self.newversion + "\\DatabaseObjects") # Copy ad-hoc scripts ibslib.copyFiles(self.branchPath + "\\CreateCI_DB\\CI_CENTRAL\\UpdateScripts\\*.*", self.branchPath + "\\IC Main Scripts\\CI_CENTRAL\\" + self.newversion) ibslib.copyFiles(self.branchPath + "\\CreateCI_DB\\CI_QUEUEDATA\\UpdateScripts\\*.*", self.branchPath + "\\IC Main Scripts\\CI_QUEUEDATA\\" + self.newversion) ibslib.copyFiles(self.branchPath + "\\CreateCI_DB\\CI_BUSINESSDATA\\UpdateScripts\\*.*", self.branchPath + "\\IC Main Scripts\\CI_BUSINESSDATA\\" + self.newversion) # Delete ad-hoc scripts from TFS ibslib.tfsDelete(self.branchPath + "\\CreateCI_DB\\CI_CENTRAL\\UpdateScripts\\*.*", self.options.tfs_user, self.options.tfs_pass) ibslib.tfsDelete(self.branchPath + "\\CreateCI_DB\\CI_QUEUEDATA\\UpdateScripts\\*.*", self.options.tfs_user, self.options.tfs_pass) ibslib.tfsDelete(self.branchPath + "\\CreateCI_DB\\CI_BUSINESSDATA\\UpdateScripts\\*.*", self.options.tfs_user, self.options.tfs_pass) # Delete intermediary files ibslib.delFiles(self.branchPath + "\\CreateCI_DB\\CI_CENTRAL\\UpdateScripts\\" + self.newversion) ibslib.delFiles(self.branchPath + "\\CreateCI_DB\\CI_QUEUEDATA\\UpdateScripts\\" + self.newversion) ibslib.delFiles(self.branchPath + "\\CreateCI_DB\\CI_BUSINESSDATA\\UpdateScripts\\" + self.newversion) # Add branch scripts to TFS ibslib.tfsAdd(self.branchPath + "\\IC Main Scripts\\CI_CENTRAL\\" + self.newversion, self.options.tfs_user, self.options.tfs_pass) ibslib.tfsAdd(self.branchPath + "\\IC Main Scripts\\CI_QUEUEDATA\\" + self.newversion, self.options.tfs_user, self.options.tfs_pass) ibslib.tfsAdd(self.branchPath + "\\IC Main Scripts\\CI_BUSINESSDATA\\" + self.newversion, self.options.tfs_user, self.options.tfs_pass) # Check in files ibslib.tfsCheckin(self.branchPath + "\\CreateCI_DB", "PackageBuildICMain script: Deleting IC Main update scripts", self.options.tfs_user, self.options.tfs_pass) ibslib.tfsCheckin(self.branchPath + "\\IC Main DLL", "PackageBuildICMain script: Updating IC Main DLLs", self.options.tfs_user, self.options.tfs_pass) ibslib.tfsCheckin(self.branchPath + "\\IC Main Scripts", "PackageBuildICMain script: Adding new IC Main DB Scripts", self.options.tfs_user, self.options.tfs_pass) self.zipfilenameDLL = self.branchPath + "\\IC Main " + self.newversion + " DLL.zip" self.zipfilenameDBScripts = self.branchPath + "\\IC Main " + self.newversion + " DBScripts.zip" # Create destination folders ibslib.makeDir(self.options.projectroot + "\\Setup") ibslib.makeDir(self.options.projectroot + "\\Setup\\Deploy") # Delete any previous zip files if they exist ibslib.delFiles(self.targetpath + "\\*.zip") ibslib.delFiles(self.branchPath + "\\*.zip") # Create DLL zip file buildzipfile = zipfile.ZipFile(self.zipfilenameDLL, "w") for name in ibslib.getFilesRecursive(self.branchPath + "\\IC Main DLL", "*.*"): relativepath = name.split("IC Main DLL\\")[1] print("Compressing - %s" % relativepath) buildzipfile.write(name, relativepath, zipfile.ZIP_DEFLATED) buildzipfile.close() # Create DBScripts zip file buildzipfile = zipfile.ZipFile(self.zipfilenameDBScripts, "w") for name in ibslib.getFilesRecursive(self.branchPath + "\\IC Main Scripts", "*.*"): relativepath = name.split("IC Main Scripts\\")[1] print("Compressing - %s" % relativepath) buildzipfile.write(name, relativepath, zipfile.ZIP_DEFLATED) buildzipfile.close() # Copy artifacts for TeamCity ibslib.copyFiles(self.branchPath + "\\*.zip", self.targetpath)