Commit b65c515f authored by dwentzel's avatar dwentzel

adding stuff

parent 62c8ee7e
@ECHO OFF
REM Vars
SETLOCAL ENABLEDELAYEDEXPANSION
SET TFPATH="c:\program files\Microsoft Visual Studio 9.0\Common7\Tools"
SET TFServer=http://STP2:8080
SET TFUser=MAXGATE\tfsservice
SET MyLocation="%CD%"
SET SQLServer="(local)\PCMX"
REM this is my net new database, we delete this before every run
SET NETNEW="NETNEW"
REM net start "SQL Server (SQLEXPRESS)"
REM this is my MaxDemoDB...we delete this before every run
SET PORTED="MaxDemoDB"
SET WorkingFolder="c:\logs"
MD %WorkingFolder%
FOR /F "eol=; tokens=1,2,3 delims=," %%i in (branches.txt) do (
REM --------------------------------------------------------------------------------------------------
REM Internal Loop Vars from branches.txt
SET CITSourcePath=%%k
SET CITWorkSpaceName=%%j
SET TFScriptsPath=%%i
@EcHO Running CIT for %%i %%j %%k
@ECHO !SQLServer! !NETNEW1 !PORTED! !WorkingFolder! !MyLocation!
REM --------------------------------------------------------------------------------------------------
REM --------------------------------------------------------------------------------------------------
REM Setup TFS
REM
call %TFPATH%\vsvars32.bat
cd /D c:\
echo YES|tf workspace /delete %%j /s:%TFServer%
md %%k
cd %%k
echo y|del %%k\*.*
tf workspace /new /s:%TFServer% /noprompt %%j;%TFUser%
tf workfold /server:%TFServer% /workspace:%%j /map %%i %%k
tf get %%k /force /recursive
REM --------------------------------------------------------------------------------------------------
REM --------------------------------------------------------------------------------------------------
REM Setup DB Env
REM blow away NETNEW and MaxDemoDB if they exist
cscript //E:vbscript %MyLocation%\manipulate_db.v-b-s %SQLServer% %WorkingFolder% %NETNEW% %MyLocation%
cscript //E:vbscript %MyLocation%\manipulate_db.v-b-s %SQLServer% %WorkingFolder% %PORTED% %MyLocation%
REM
REM --------------------------------------------------------------------------------------------------
REM this is set in setup.vbs as one of the first steps.
@echo %MasterLogFile%
REM --------------------------------------------------------------------------------------------------
ECHO Run Porting
cscript //E:vbScript //Nologo setup.vbs %SQLServer% %PORTED% "" "" %WorkingFolder% "" "x.x.x" %WorkingFolder%
ECHO ERRORLEVEL from %PORTED% call to setup.vbs is !ERRORLEVEL!
IF !ERRORLEVEL!==1 (
cscript //E:vbscript %MyLocation%\mail.v-b-s "FAILURE" %%i
echo Failure Email Sent
) ELSE (
echo Running %NETNEW%
cscript //E:vbScript //Nologo setup.vbs %SQLServer% %NETNEW% "" "" %WorkingFolder% "" "x.x.x" %WorkingFolder%
ECHO ERRORLEVEL from %NETNEW% call to setup.vbs is !ERRORLEVEL!
IF !ERRORLEVEL!==1 (
cscript //E:vbscript %MyLocation%\mail.v-b-s "FAILURE" %%i
echo Failure Email Sent
) ELSE (
cscript //E:vbScript //Nologo GenerateDiscrepancyReport.vbs %SQLServer% "" "" %WorkingFolder% %NETNEW% %PORTED%
cscript //E:vbscript %MyLocation%\mail.v-b-s "SUCCESS" %%i
)
)
)
REM --------------------------------------------------------------------------------------------------
REM Cleanup DB Env
REM blow away NETNEW and MaxDemoDB if they exist
cscript //E:vbscript %MyLocation%\manipulate_db.v-b-s %SQLServer% %WorkingFolder% %NETNEW% %MyLocation%
cscript //E:vbscript %MyLocation%\manipulate_db.v-b-s %SQLServer% %WorkingFolder% %PORTED% %MyLocation%
REM
REM --------------------------------------------------------------------------------------------------
REM --------------------------------------------------------------------------------------------------
REM cleanup WorkingFolder
rd /S/Q %WorkingFolder%
REM --------------------------------------------------------------------------------------------------
ENDLOCAL
\ No newline at end of file
REM Vars
SET TFPATH="c:\program files\Microsoft Visual Studio 8\Common7\Tools"
SET CITSourcePath="C:\Projects\Development\STP Database\scripts"
SET CITWorkSpaceName=DWENTZELLP
SET TFServer=STP
SET TFUser=MAXGATE\dwentzel
SET TFScriptsPath="$/MaxwellSTP/Development/STP Database/Scripts"
SET MyLocation=%CD%
SET SQLServer="(local)\PROCONTRACTORMX"
SET NETNEW="NETNEW"
SET PORTED="MaxDemoDB"
call %TFPATH%\vsvars32.bat
cd /D c:\
tf get %CITSourcePath% /force /recursive
:END
;this lists the branches we wish to execute CIT for
;each line takes the form "TFScriptsPath","CITWorkSpaceName","CITSourcePath"
"$/MaxwellSTP/Development/STP Database/Scripts","CIT_TRUNK","c:\CIT_TRUNK"
"$/MaxwellSTP/Releases/2.3/STP Database/Scripts","CIT_2.3","c:\CIT_2.3"
"$/MaxwellSTP/Branches/EstRounding/STP Database/Scripts","CIT_EstRounding","c:\CIT_EstRounding"
"$/MaxwellSTP/Branches/TimeImport/STP Database/Scripts","CIT_TimeImport","c:\CIT_TimeImport"
"$/MaxwellSTP/Branches/ITB/STP Database/Scripts","CIT_ITB","c:\CIT_ITB"
'Name: smtp_mail_test.vbs
'Date: 20040322
'Purpose: tests connectivity to send smtp mail from a given server.
'
'Developer History:
'Name Date Change Description
'
'
'
Set args = Wscript.Arguments
For iArg = 0 To args.count -1
MsgToEmail = args(0)
BranchPath = args(1)
Next
smtpserver="kopexch2.maxwellsystems.com"
fromemail="CITProcess@maxwellsystems.com"
toemail = "dwentzel@maxwellsystems.com;jprodgers@maxwellsystems.com"
Call Mailer ("Success")
wscript.sleep 5000
Public Sub Mailer (Status)
Dim iMsg, iConf, iBp, Flds, EUsrs
Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")
Set Flds = iConf.Fields
Flds("http://schemas.microsoft.com/cdo/configuration/smtpserver") = smtpserver
Flds("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
Flds("http://schemas.microsoft.com/cdo/configuration/sendemailaddress") = """CP"" dwentzel@maxwellsystems.com"
Flds("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoAnonymous ' 0
Flds("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
Flds.Update
EUsrs = toemail
set shell = CreateObject("wscript.shell")
set sysEnv = shell.Environment("SYSTEM")
if MsgToEmail = "SUCCESS" then
BodyText = "CIT succeeded for branch path: " & BranchPath
'for success cases we want to email the discrepancies file always...but no log file
LogFile = "NoFileNeeded"
DiscrepFile = sysEnv("DiscrepLogFile")
elseif MsgToEmail = "FAILURE" then
BodyText = "CIT failed, examine logs for branch path: " & BranchPath
'For failure cases we need the log file but not the discrepancy file since it won't exist
LogFile = sysEnv("MasterLogFile")
DiscrepFile = "NoFileNeeded"
elseif MsgToEmail = "TEST" then
BodyText = "test of smtp"
DiscrepFile = "NoFileNeeded"
LogFile = "NoFileNeeded"
end if
With iMsg
'Apply Configuration and prepare to send file
Set .Configuration = iConf
.To = EUsrs
.Cc = ""
.From = fromemail
.Sender = fromemail
.Subject = BodyText
.TextBody = BodyText
if LogFile <> "NoFileNeeded" Then
Set iBP = .AddAttachment(LogFile)
iBP.ContentMediaType="application/zip"
End If
if DiscrepFile <> "NoFileNeeded" Then
Set iBP = .AddAttachment(DiscrepFile)
iBP.ContentMediaType="application/zip"
End If
.Send
End With
Set iMsg = Nothing
Set iConf = Nothing
Set Flds = Nothing
End Sub
\ No newline at end of file
Const ForReading = 1, ForWriting = 2, ForAppending = 8
quote = """"
ErrorEncountered = 0
set oFso = CreateObject("Scripting.FileSystemObject")
Dim iArg, args
Set args = Wscript.Arguments
'parse out the args
For iArg = 0 To args.count -1
server_instancename = args(0)
SQLAccessPath = args(1)
DBToActOn = args(2)
MyPath = args(3)
Next
strQuery = "if exists (select * from sys.databases where name = '" & DBToActOn & "') begin alter database " & DBToActOn & " set single_user with rollback immediate; drop database " & DBToActOn & "; end"
'msgbox strQuery
Call OSQLforProcedure (strQuery,"master")
'cleanup
Set oFso = Nothing
wscript.quit(ErrorEncountered)
'Subs and Functions
Public Sub OSQLforProcedure (CmdString,dbcontext)
'calls osql for a stored procedure
'logs output using >> (appends to existing LgFile
strQuery = quote & CmdString & quote
strCommand = "cmd /C " & quote & quote & MyPath & "\osql" & quote & " -S" & quote & server_instancename & quote & " -n -w300 -d" & quote & dbcontext & quote & " -E" & " -Q" & strQuery & quote
Set shell = WScript.CreateObject ("WSCript.shell")
shell.run strCommand,,TRUE
set Shell = Nothing
End Sub
Public Sub OSQLforFile (FileAndPath,LgFile,dbcontext)
'calls osql for a file
'logs output using >> (appends to existing LgFile
strQuery = quote & CmdString & quote
strCommand = "cmd /C " & quote & quote & MyPath & "\osql" & quote & " -S" & quote & server_instancename & quote & " -n -w300 -d" & quote & dbcontext & quote & " -E" & " -i" & quote & FileAndPath & quote & quote
Set shell = WScript.CreateObject ("WSCript.shell")
shell.run strCommand,,TRUE
set Shell = Nothing
End Sub
This diff is collapsed.
a repository for publicly available SQL Scripts I've created and moved from my website into a proper VCS.
\ No newline at end of file
a repository for publicly available SQL Scripts I've created and moved from my website into a proper VCS.
DBA-in-a-Box : this is a process I've been using since SQL 6.5 that will quickly set up general database
hygiene processes when I don't have a dedicated DBA available to me.
MyOldCITProcess : This is an example continuous integration process that I used years ago to automate database
build testing. http://www.davewentzel.com/content/doing-database-cit-tfs
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment