If those values of MyVariable are constant (I mean always the same for given task) then I'd use preprocessor. Then you can override the value with cb:scope.
For example, here's what I do with projects configuration:
<cb:scope
Project.Name = "ProjectName - Feedback - Integration tests"
Project.ShortName = "project-name-feedback-quick"
Project.Category = "Project Name - Feedback"
Project.Description = "Run integration tests"
>
<project name="$(Project.Name)" description="$(Project.Description)">
<artifactDirectory>$(CIRootFolderPath)\$(Project.ShortName)\Artifacts</artifactDirectory>
<workingDirectory>$(CIRootFolderPath)\$(Project.ShortName)\WorkingDir</workingDirectory>
<state type="state" directory="$(CIRootFolderPath)\$(Project.ShortName)" />
So you would surround each <task>
with <cb:scope>
block and redefine value of MyVariable in there.