I'm attempting to automate the use of Vault with Red Gate SQL Compare for an article for publication on Simple-Talk.com. I've hit a snag and I'm hoping there's a resolution.
I have to be able to capture changes to existing scripts and check them into source control, but I also have to be able to capture new scripts and check them into source control as well. The only way I've found so far that works is to individually name the scripts for adding through the command line. Is there no way to identify new files within a working folder from the command line? The GUI is not an option since this is meant to be an automated process of auditing changes and capturing those changes into source control.
Any help here would be appreciated.
Automate ADD w/Command Line
Moderator: SourceGear
Re: Automate ADD w/Command Line
I've tried to put in a work-around, but I'm unsure how to proceed from here. It's all in PowerShell. This is the line that will capture changes:
Get-ChildItem $Scripts\$DBName -Recurse | where-Object{!$_.PsIsContainer} | where-Object{$_.CreationTime -gt $Date} | foreach-object {./vault ADD -user admin -password cthulhu88 -host Bob -repository Ivy -commit $/$DBName $_.FullName}
The only problem is, I'm not sure how to get the files into the correct repository. I'm able to figure out which ones have been added, but I still can't get them into the folder in the repository.
Get-ChildItem $Scripts\$DBName -Recurse | where-Object{!$_.PsIsContainer} | where-Object{$_.CreationTime -gt $Date} | foreach-object {./vault ADD -user admin -password cthulhu88 -host Bob -repository Ivy -commit $/$DBName $_.FullName}
The only problem is, I'm not sure how to get the files into the correct repository. I'm able to figure out which ones have been added, but I still can't get them into the folder in the repository.
Re: Automate ADD w/Command Line
There isn't currently a "Detect files to add" function in the CLC, nor is there a wildcard capability for an "Add."
The only way to add files is by file name or by adding an entire folder.
We have feature 13815 request logged for this functionality; I'll add your vote.
It will be evaluated for an upcoming release of Vault.
The only way to add files is by file name or by adding an entire folder.
We have feature 13815 request logged for this functionality; I'll add your vote.
It will be evaluated for an upcoming release of Vault.
Linda Bauer
SourceGear
Technical Support Manager
SourceGear
Technical Support Manager
Re: Automate ADD w/Command Line
Got it all to work with this code:
Get-ChildItem $Scripts\$DBName -Recurse | where-Object{!$_.PsIsContainer} | where-Object{$_.CreationTime -gt $Date} | foreach-object {./vault ADD -user admin -password x -host Bob -repository Ivy -commit ("$" + $_.FullName.Replace($Scripts,"").Replace("\"+$_.Name,"").Replace("\","/")) $_.FullName}
Only trick is getting a creation time back a couple of minutes to be sure I'm getting files generated from SQL Compare. That's possibly problematic if people let other processes add files to the folders, but good enough for purposes of the article. Others might find this handy.
Get-ChildItem $Scripts\$DBName -Recurse | where-Object{!$_.PsIsContainer} | where-Object{$_.CreationTime -gt $Date} | foreach-object {./vault ADD -user admin -password x -host Bob -repository Ivy -commit ("$" + $_.FullName.Replace($Scripts,"").Replace("\"+$_.Name,"").Replace("\","/")) $_.FullName}
Only trick is getting a creation time back a couple of minutes to be sure I'm getting files generated from SQL Compare. That's possibly problematic if people let other processes add files to the folders, but good enough for purposes of the article. Others might find this handy.
Re: Automate ADD w/Command Line
Thanks for the update. That's good news. : )
We'd love to get a link to your article when it's done.
We'd love to get a link to your article when it's done.
Linda Bauer
SourceGear
Technical Support Manager
SourceGear
Technical Support Manager