Create Directory/Run Dos Command- source path expansion

In the 'Create Folder' action, the following value the 'Path' results in 'MyDirecetory' being created directly in the workspace rather than under the source path:

$Source.MyRepo$\MyDirectory


Related, the 'Run DOS Command' action has a similar problem - the $Source$ just seems to be ignored:

$Source.MyRepo$\mybatchfile.bat

Results is a failed build, with the error:

'\mybatchfile.bat' is not recognized as an internal or external command, operable program or batch file.

Ouch, we’ll get that fixed.

Hi Joel

Can you show what your Repository Rules are for that stage.

We’ve been looking at the source for this and it would seem to indicate that there is no source rule that matches the repository. I think we probably should be throwing an exception where a reference to $Source.repo$ is used when there are no matching repository rules.

For that stage, I don't have any repository rules at all. I'm relying on the bat file being there from the repository rules in the stage before.

Ok that makes sense. But in some cases wouldn't that mean that some source copies will be doubled up across stages - or is it smarter than that?

If it’s running on the same agent as a prior stage and the rules are the same, it’s smart enough to only copy what it needs (the cache on the agent is a mercurial repository, and it’s very effecient). The issue here is that if there are no rules for the stage then the agent doesn’t know where to look, and it can’t just uses the rules from the previous stage as that may have run on a different agent

The whole reason we implemented the repository rules (fairly recently) was to cut down on needless IO copying the source code into the workspace on stages where it might not be needed. The rules allow you to only copy what you need.

I think we need to take a look at what to do when $Source.Repo$ is referenced when there are no matching rules, it really should throw and exception because otherwise you get the behavior you were seeing, which is neither as desired or particularly useful.

Thanks Vincent! Now that I understand that concept, I realise I've been ordering things incorrectly. I've been doing all my source copies in the first stage, regardless of what stage I actually need them - I guess I incorrectly surmised from $Source$>$Source$ default rule what I should be doing, and didn't stop to think about it (and there really isn't another option for the default rule).

Your way makes much more sense, and it's a lot easier to manage the build stages

Following the rule that each stage should be responsible for it's own repo copying (roughly), it looks like the following is not enough to get a valid $Source.MyRepo$ variable:

$Source.MyRepo$\foo\**.bar > Source\MyRepo

Attempting to use $Source.MyRepo$ in a stage with only this rule results in an empty string. You seem to need the following to get the desired files and a valid $Source.MyRepo$ variable:

$Source.MyRepo$ > Source\MyRepo
-$Source.MyRepo$\anotherfoo\** > Source\MyRepo
- { numerous other directory/file exclusions }

or

$Source$ > Source
-$Source.MyRepo$ > Source\MyRepo
-$Source.AnotherRepo$ > Source\AnotherRepo
- { other repo exclusions here }
$Source.MyRepo$\foo\**.bar > Source\MyRepo

This exclusion stuff gets pretty tricky to maintain. I may have missed something again, but shouldn't the first example be enough to get a valid $Source.MyRepo$ variable value without having to resort to an entire repo copy coupled with exclusions?

I tried to be clever and do something like:

$Source.MyRepo$ > Source\MyRepo
-$Source.MyRepo$ > Source\MyRepo
$Source.MyRepo$\foo\**.bar > Source\MyRepo

That gave my a valid $Source.MyRepo$ variable, but nothing in the folder for obvious reasons

Hi Joel

Vinnie just pointed me to the doco (lol!) : http://wiki.finalbuilder.com/display/continua/Repository+Rules

When copying part of a repository, there is no way to infer the path that $Source.MyRepo$ points to, with this rule :

$Source.MyRepo$\foo*.bar > Source\MyRepo

Where would you expect $Source.MyRepo$ to point to? Then there may also be other rules which further complicate things:

$Source.MyRepo$\foo*
.bar > Source\MyRepo
$Source.MyRepo$\bar**.foo > Source\Fooey

The solution is to not use $Source.MyRepo$ in the actions, just use the path you have in your rules, ie \Source\MyRepo - this will be relative to the root of the build workspace. The down side to that is it’s sort of ‘hard coded’. We’re looking into whether we can expand variables in the rules… can’t promise that will be possible, but that might make it a bit less hard coded then.

That makes a lot of sense. Thanks for bearing with me guys.

I guess you could always write the path to a variable as well to avoid the hard coding.

Well the good news is that Vinnie got variables working in the rules just before we left for the day, needs a bit of tidying up but should be in tomorrow’s build.