Rev 4624 | Blame | Last modification | View Log | RSS feed
<%'=====================================================' release_changed.asp'=====================================================%><%' Release Change ModeConst enumRELEASE_CHANGE_MODE_PKG_ADDED = 1 'Package added to releaseConst enumRELEASE_CHANGE_MODE_PKG_REMOVED = 2 'Package removed from releaseConst enumRELEASE_CHANGE_MODE_PKG_RELEASED = 3 'Package releasedClass ReleaseChangedprivate m_pkg_nameprivate m_pkg_versionprivate m_pkg_idprivate m_proj_id' Archive server name and credentials' Perhaps the credentials should come from the environmentprivate m_archive_serverprivate m_archive_userprivate m_archive_passwordPublic last_resultCode'-----------------------------------------------------------------------------------------------------------------' Retrieve information about the target server'Private Sub Get_Server_Info()m_archive_user = "releasem"m_archive_password = "releasem"Dim sqry: sqry = "SELECT * FROM BUILD_SERVICE_CONFIG WHERE SERVICE='ARCHIVE SERVER'"Dim rsTempSet rsTemp = OraDatabase.DbCreateDynaset( sqry , cint(0) )m_archive_server = rsTemp("config")rsTemp.Close()Set rsTemp = NothingEnd Sub'-----------------------------------------------------------------------------------------------------------------' Retrieves package infomation for the specified package version' This information is required for the make_release_changed scriptPublic Sub Get_Package_Info (artag_id,apv_id)Dim ssql, rsTemp' Get package informationssql = _" SELECT pv.pkg_id,pk.pkg_name,pv.pkg_version,rt.proj_id"&_" FROM package_versions pv, packages pk, release_tags rt"&_" WHERE" &_" pv.pv_id = " & apv_id &_" AND pv.pkg_id = pk.pkg_id" &_" AND rt.rtag_id = " & artag_idSet rsTemp = OraDatabase.CreateDynaset( ssql, cint(0))If ((NOT rsTemp.BOF) AND (NOT rsTemp.EOF)) Thenm_pkg_name = rsTemp("pkg_name")m_pkg_version = rsTemp("pkg_version")m_pkg_id = rsTemp("pkg_id")m_proj_id = rsTemp("proj_id")ElseErr.Raise 8, "Error getting package information. PV_ID, " & APV_ID & " not found in."Call RaiseMsg ( enum_MSG_ERROR, Err.description )End IfrsTemp.CloseSet rsTemp = NothingEnd Sub'-----------------------------------------------------------------------------------------------------------------' Run script job, ReleaseChanged, of script, on_Make_Official.wsf for the specified list of package versions.' apv_id_list is a comma separated list of pv_id'sSub Run_ReleaseChanged_List(artag_id,apv_id_list,amode_id)Dim pv_id, idArridArr = Split(apv_id_list,",")For Each pv_id in idArrIf IsReleased(artag_id,pv_id) ThenCall Run_ReleaseChanged(artag_id,pv_id,amode_id,true)End IfNextEnd Sub'-----------------------------------------------------------------------------------------------------------------' Run script job, ReleaseChanged, of script, on_Make_Official.wsf for the specified package version.' This job calls the unix script, make_release_changedSub Run_ReleaseChanged(artag_id,apv_id,amode_id,aget_info)Dim sysShell: Set sysShell = Server.CreateObject("WScript.Shell")if aget_info thenCall Get_Package_Info (artag_id,apv_id)end if' Note: Call Run such that we wait for the result code' If we don't do this then we may flood the server with requests and then it jams up.'Call sysSHell.Run("cmd.exe /c cscript.exe //B //NoLogo " & rootPath & SCRIPTS_FOLDER &"\on_Make_Official.wsf //job:ReleaseChanged" & " /pkg_name:""" & m_pkg_name & """" & " /pkg_version:""" & m_pkg_version & """" & " /rtag_id:" & artag_id & " /pkg_id:" & m_pkg_id & " /pv_id:" & apv_id & " /proj_id:" & m_proj_id & " /mode_id:" & amode_id, 0, True)Set sysShell = NothingEnd Sub'-----------------------------------------------------------------------------------------------------------------' Uses ssh to communicate with the archive server and run the unix script, make_release_changed' Current Issue: Does not have nice error reporting mechanism'Sub Run_ReleaseChanged_New_and_not_yet_used(artag_id,apv_id,amode_id,aget_info)Dim sudoCmd, plinkPath, plinkCmd, wCmdLinelast_resultCode = -1Call Get_Server_Infoif aget_info thenCall Get_Package_Info (artag_id,apv_id)end if'' Build up the command line to the target script'sudoCmd = "~/sbin/make_release_changed" &_" archive=dpkg_archive" &_" pkg_name='\""" & m_pkg_name & "\""'" &_" pkg_version='\"""& m_pkg_version &"\""'" &_" rtag_id="& artag_id &_" pkg_id=" & m_pkg_id &_" pv_id="& apv_id &_" proj_id="& m_proj_id &_" mode_id="& amode_id' Build up the ssh commandplinkPath = Request.ServerVariables("APPL_PHYSICAL_PATH") & "Release_Manager\scripts\bin\plink.exe"plinkCmd = "-ssh -batch " & m_archive_user & "@" & m_archive_server & " -pw " & m_archive_password & " ""sudo " & sudoCmd & ";"""wCmdLine = plinkPath & " " & plinkCmd' Note: Call Run such that we wait for the result code' If we don't do this then we may flood the server with requests and then it jams up.'Dim objWSHSet objWSH = Server.CreateObject("WScript.Shell")last_resultCode = objWSH.Run (wCmdLine, 0, TRUE)Set objWSH = NothingEnd Sub'-----------------------------------------------------------------------------------------------------------------------------' Get the package are in which the package version resides (ie wip, planned, released)Function Get_Pkg_Area (artagId, apvId)OraDatabase.Parameters.Add "RTAG_ID", artagId, ORAPARM_INPUT, ORATYPE_NUMBEROraDatabase.Parameters.Add "PV_ID", apvId, ORAPARM_INPUT, ORATYPE_NUMBEROraDatabase.Parameters.Add "PKG_AREA", -1, ORAPARM_OUTPUT,ORATYPE_NUMBEROraDatabase.ExecuteSQL _"BEGIN "&_" :PKG_AREA := PK_ENVIRONMENT.GET_PACKAGE_AREA ( :PV_ID, :RTAG_ID ); "&_"END; "Get_Pkg_Area = OraDatabase.Parameters("PKG_AREA").ValueOraDatabase.Parameters.Remove "RTAG_ID"OraDatabase.Parameters.Remove "PV_ID"OraDatabase.Parameters.Remove "PKG_AREA"End Function'-----------------------------------------------------------------------------------------------------------------------------' Returns TRUE if the specified package is releasedFunction IsReleased (artagId, apvId)IsReleased = (CInt(Get_Pkg_Area(artagId, apvId)) = CInt(enum_PKG_AREA_RELEASED))End FunctionEnd Class%>