Automate ADD w/Command Line

If you are having a problem using Vault, post a message here.

Moderator: SourceGear

Post Reply
GFritchey
Posts: 4
Joined: Wed Aug 17, 2011 10:51 am

Automate ADD w/Command Line

Post by GFritchey » Wed Aug 17, 2011 11:14 am

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.

GFritchey
Posts: 4
Joined: Wed Aug 17, 2011 10:51 am

Re: Automate ADD w/Command Line

Post by GFritchey » Wed Aug 17, 2011 1:57 pm

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.

lbauer
Posts: 9736
Joined: Tue Dec 16, 2003 1:25 pm
Location: SourceGear

Re: Automate ADD w/Command Line

Post by lbauer » Wed Aug 17, 2011 3:12 pm

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.
Linda Bauer
SourceGear
Technical Support Manager

GFritchey
Posts: 4
Joined: Wed Aug 17, 2011 10:51 am

Re: Automate ADD w/Command Line

Post by GFritchey » Thu Aug 18, 2011 8:16 am

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.

lbauer
Posts: 9736
Joined: Tue Dec 16, 2003 1:25 pm
Location: SourceGear

Re: Automate ADD w/Command Line

Post by lbauer » Thu Aug 18, 2011 9:15 am

Thanks for the update. That's good news. : )

We'd love to get a link to your article when it's done.
Linda Bauer
SourceGear
Technical Support Manager

Post Reply