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.
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.
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$ > 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?
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.
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.