Kinook Software Forum

Go Back   Kinook Software Forum > Visual Build Professional > [VBP] General Discussion
FAQ Community Calendar Today's Posts Search

 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 03-04-2010, 05:36 PM
citect citect is online now
Registered User
 
Join Date: 11-13-2008
Posts: 30
builder.CompletionStatus and vbld_BuildDone()

Hi

I have got the project script below. The function "CreateXmlLogHandlingProject()" is working fine if "status" = vbldBuildCompFailed but it fails to run when "status" = vbldBuildCompDone or "status" = vbldBuildCompAborted.
When the script failed the last msgbox displayed is "Test 3".


Script:


Option Explicit

Function LogExt()

If Application.Options.LogFormat = "Text" Then
LogExt = "txt"
Else
LogExt = "xml"
End If

End Function


Function vbld_BuildStarting()
' delete any existing log file before the build begins
' This can be useful if a master project calls child projects
' which use the same log file as the master project, but the
' log file should be deleted only at the start of the master build.
' The global option 'Tools | Application Options | Logging | Delete
' log file at the start of each build' would cause the log file to
' be deleted at the beginning of the master and each child project,
' so instead that option can be unchecked and this step added to the
' start of the master project.

Dim logFile, message

' determine the log filename, retrieve with all macros/script expanded
logFile = Application.ExpandMacrosAndScript("%LOGFILE%")

' delete the file if it exists
If vbld_FSO.FileExists(logFile) Then
message = "Deleting log file '" + logFile + "' from vbld_BuildStarting event (go to Script Editor, Project tab to view script code)."
Builder.LogMessage vbCrLf + message + vbCrLf

vbld_FSO.DeleteFile logFile, True
End If
End Function


Function vbld_BuildDone(status)
CreateXmlLogHandlingProject(status)
End Function




Dim objApp, objBld, objStep, objMacro
Dim toEmailObjMacro, emailSubjectObjMacro, emailContentObjMacro

Function CreateXmlLogHandlingProject(status)

' create VisBuildPro app and build objects and connect
Set objBld = CreateObject("VisBuildSvr7.Builder")
Set objApp = CreateObject("VisBuildSvr7.Application")

objBld.Initialize objApp

' create a "XmlFilePath" macro containing the path of this project log file
Set objMacro = objApp.Project.Macros.Add("XmlFilePath")
objMacro.Value = Application.ExpandMacrosAndScript("%LOGFILE%")

' create a "HtmlFilePath" macro containing the path of the log file transformation result
Set objMacro = objApp.Project.Macros.Add("HtmlFilePath")
objMacro.Value = "%TEMP%\%PROJROOT%.html"
objMacro.Value = Application.ExpandMacrosAndScript(objMacro.Value)

' create a "LogFormat" macro indicating the format of this project log file
Set objMacro = objApp.Project.Macros.Add("LogFormat")
objMacro.Value = Application.Options.LogFormat

msgbox "status = " & status, vbOK, "CreateXmlLogHandlingProject"
msgbox "Test 1", vbOK, "CreateXmlLogHandlingProject"

' create a "TO_EMAIL" macro containing the email distribution list
Set objMacro = objApp.Project.Macros.Add("TO_EMAIL")
Select case status
case vbldBuildCompDone
objMacro.Value = ""%myEmail%"
case vbldBuildCompAborted
objMacro.Value = ""%myEmail%"
case vbldBuildCompFailed
objMacro.Value = "%myEmail%"
case else
objMacro.Value = ""%myEmail%"
end Select

msgbox "Test 2, objMacro.Value = " & objMacro.Value, vbOK, "CreateXmlLogHandlingProject"

' create a "EmailSubject" macro containing the subject of the email
Set objMacro = objApp.Project.Macros.Add("EmailSubject")

msgbox "Test 3", vbOK, "CreateXmlLogHandlingProject"

Select case status
case vbldBuildCompDone
objMacro.Value = "Nightly Build Result (COMPLETED)"
case vbldBuildCompAborted
objMacro.Value = "Nightly Build Result (ABORTED)"
case vbldBuildCompFailed
objMacro.Value = "Nightly Build Result (FAILED)"
case else
objMacro.Value = "Nightly Build Result (UNKNOWN STATUS='" + CStr(status) + "')"
end Select

msgbox "Test 4, objMacro.Value = " & objMacro.Value, vbOK, "CreateXmlLogHandlingProject"

' create a "EmailContent" macro containing the content of the email
Set objMacro = objApp.Project.Macros.Add("EmailContent")

msgbox "Test 5", vbOK, "CreateXmlLogHandlingProject"

Select case status
case vbldBuildCompDone
objMacro.Value = Application.ExpandMacrosAndScript("At %DATETIME%, the build '%PROJFILE%' on %COMPUTERNAME% completed successfully.") + vbCrLf + vbCrLf + vbCrLf
case vbldBuildCompAborted
objMacro.Value = Application.ExpandMacrosAndScript("At %DATETIME%, the build '%PROJFILE%' on %COMPUTERNAME% was canceled by the user.") + vbCrLf + vbCrLf + vbCrLf
case vbldBuildCompFailed
objMacro.Value = Application.ExpandMacrosAndScript("At %DATETIME%, the build '%PROJFILE%' on %COMPUTERNAME% failed.") + vbCrLf + vbCrLf + vbCrLf
case else
objMacro.Value = Application.ExpandMacrosAndScript("At %DATETIME%, the build '%PROJFILE%' on %COMPUTERNAME% exit with unknow status: '") + CStr(status) + "'" + vbCrLf + vbCrLf + vbCrLf
end Select

msgbox "Test 6, objMacro.Value = " & objMacro.Value, vbOK, "CreateXmlLogHandlingProject"

' add a "Group" step and set its properties
With CreateStep(vbldStepMain, "Group", "XML log handling", 0)
.Property("condcomparison") = 6
.Property("condexpr") = "[Len(%QUOTE_STR(%XmlFilePath%)%) > 0 And ""%LogFormat%"" = ""XML""]"
.Property("description") = "Show extra capabilities for XML log files only, processed only if log format is XML"
End With

msgbox "Test 7", vbOK, "CreateXmlLogHandlingProject"

' add a "Transform XML Log" step and set its properties
With CreateStep(vbldStepMain, "Transform XML Log", "Generate HTML log", 1)
.Property("Build0") = -1
.Property("Build1") = -1
.Property("Build2") = -1
.Property("CloseTags") = -1
.Property("InputFile") = "%XmlFilePath%"
.Property("Log0") = -1
.Property("Log1") = -1
.Property("Log2") = -1
.Property("Log3") = -1
.Property("Log4") = -1
.Property("LogNested") = -1
.Property("OutputFile") = "%HtmlFilePath%"
.Property("ShowFile") = -1
.Property("Step0") = -1
.Property("Step1") = -1
.Property("Step2") = -1
.Property("Step3") = -1
.Property("Step4") = -1
.Property("Step5") = -1
.Property("Step6") = -1
.Property("XSLTFile") = "%VISBUILDDIR%\Style\TransformLog.xslt"
.Property("description") = "Perform transform on log file, converting to formatted HTML log with summary, uses built-in XSLT stylesheet"
End With

msgbox "Test 8", vbOK, "CreateXmlLogHandlingProject"

' add a "Send Mail" step and set its properties
With CreateStep(vbldStepMain, "Send Mail", "Send Log File", 1)
.Property("Attachments") = "%HtmlFilePath%"
.Property("Domain") = "%USERDNSDOMAIN%"
.Property("From") = "%USERNAME%@%USERDNSDOMAIN%"
.Property("Message") = "%EmailContent%"
.Property("Port") = 25
.Property("Server") = "%Server%"
.Property("Subject") = "%EmailSubject%"
.Property("Timeout") = 10
.Property("To") = "%TO_EMAIL%"
.Property("description") = "Send the log file via email"
End With


' save the project to disk to build in following step
'objApp.Project.Save "TEMP\dynamic.bld"

'MsgBox "Dynamic file location: TEMP\dynamic.bld", vbOkOnly, "Visual Build Pro"

' build the dynamic project
objBld.SyncBuild



End Function


' add a step to the project and return
Function CreateStep(typ, action, name, indent)
Set objStep = objApp.Project.Steps(typ).Add(action)
objStep.Name = name
objStep.Indent = indent
Set CreateStep = objStep
End Function
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



All times are GMT -5. The time now is 10:57 PM.


Copyright © 1999-2023 Kinook Software, Inc.