Tuesday 30 December 2014

How to create cmd file for SVN Export operation using VBScript

Option Explicit
dim objXML2,fso,strdir,CurrentDirectory,ExportFile,LocalPath,SVNPath,colNodes,objnode,backupvalue,colNodes1
Set objXML2 = CreateObject("Microsoft.XMLDOM")
objXML2.async = "false"
strdir= WScript.Arguments.item(0) '"C:\ABC.xml"

set fso = CreateObject("Scripting.FileSystemObject")
CurrentDirectory = fso.GetAbsolutePathName(".")
Set ExportFile = fso.CreateTextFile(CurrentDirectory&"\SVNExport.cmd", True)
ExportFile.WriteLine("@echo off")
ExportFile.WriteBlankLines(1)
'ExportFile.WriteLine("start /b 1")

LocalPath = "C:\SVN Export" 'WScript.Arguments.item(1)
SVNPath = "https://svn.pointcrossblr.com/svn/Devbuild/EngineeringBuild" 'WScript.Arguments.item(2)

'ExportFile.WriteLine("LocalPath: " & LocalPath)
'ExportFile.WriteLine("SVNPath: " & SVNPath)

If (Not objXML2.load(strdir)) Then
    wscript.echo "Unable to load file '" & strdir & "'. "
    WScript.Quit(1)
End If

'Set colNodes = objXML2.selectNodes ("/PRODUCTINFO/PRODUCT")
'For Each objNode in colNodes
' If backupvalue <> "" Then
' ExportFile.WriteLine("start /b %~nx0 """ & objnode.getAttribute("NAME") & """")
' ExportFile.WriteBlankLines(1)
' else
' ExportFile.WriteLine("if not " & objnode.getAttribute("NAME") & "= """" goto :" & objnode.getAttribute("NAME"))
' ExportFile.WriteBlankLines(1)
' End If
' backupvalue = objNode.getAttribute("NAME")
' ExportFile.WriteLine("echo Export Completed")
'Next
Set colNodes1 = objXML2.selectNodes ("/PRODUCTINFO/PRODUCT")
'ExportFile.WriteBlankLines(1)
For Each objNode in colNodes1
    wscript.echo objnode.getAttribute("NAME")& " : " & objnode.getAttribute("VERSION")
' ExportFile.WriteLine(":" & objnode.getAttribute("NAME"))
ExportFile.WriteLine("echo Getting " & objnode.getAttribute("NAME") & " of version " & objnode.getAttribute("VERSION") & " from SVN")
ExportFile.WriteLine("""C:\Program Files\TortoiseSVN\bin\svn.exe"" export --force """ & SVNPath & "/" & objnode.getAttribute("NAME") & "/" & objnode.getAttribute("VERSION") & """   """ & LocalPath & "\" & objnode.getAttribute("NAME") & "\" & objnode.getAttribute("VERSION") & """" & " --username praveen.v --password PNT@123ltd --no-auth-cache --non-interactive --trust-server-cert")
Next
'get the paths for each solutions

'wscript.echo objnode.getAttribute("NAME")& " : " & objnode.getAttribute("VERSION")

ExportFile.WriteLine("echo Export Completed")
'ExportFile.WriteLine("pause")
ExportFile.close()

No comments:

Post a Comment