Closed echalone closed 1 month ago
This issue has had no activity in 180 days. Please comment if it is not actually stale
Removing stale to check the request.
This issue has had no activity in 180 days. Please comment if it is not actually stale
Not actually stale, right? ^^
This issue has had no activity in 180 days. Please comment if it is not actually stale
not really stale
According to the suggestion of @ismayilov-ismayil the pull request for these changes has been recreated. It previously contained other changes too and in the new pull request these changes have been isolated and now only contain the changes needed to fix this bug. New pull request is here: https://github.com/microsoft/azure-pipelines-agent/pull/4217
This issue has had no activity in 180 days. Please comment if it is not actually stale
not stale
This issue has had no activity in 180 days. Please comment if it is not actually stale
Once upon a time, in the kingdom of the azure-pipeline-agent repository, there lurked a mischievous creature known as the GitHub Stale Bot. This bot had a peculiar habit of labeling open pull requests and feature requests with a "stale" label after half a year of inactivity. And if that wasn't enough, it would ruthlessly close these issues after another week if nobody dared to utter a word in their defense. The developers of the azure-pipeline-agent repository lived in constant fear of this relentless bot. They would toil away at their keyboards, creating magnificent lines of code, only to have their creations labeled as "stale" and cast aside into the abyss of forgotten tickets. But one day, those brave developers stood up to challenge of the GitHub Stale Bot. Armed with nothing but their wit and a keyboard they devised a cunning plan to outsmart the bot once and for all. As the deadline approached, and passed, for the bot to strike, we sprung into action. We crafted a comment so clever, so witty, that even the most heartless of bots would have to pause and reconsider its actions. The comment echoed through the digital halls of GitHub, reaching the circuits of the Stale Bot's mechanical heart. And to nobody's surprise, the bot replied: "removed the stale label" From that day forward, we became a legend in the kingdom of the azure-pipeline-agent repository. Whenever the GitHub Stale Bot threatened to strike, developers would flock to us for advice on crafting the perfect comment to save their creations.
This is that comment. This is our story.
This issue has had no activity in 180 days. Please comment if it is not actually stale
Synopsis
In some cases the first repository checked out in a Yaml pipeline with a multiple repository checkout scenario is wrongly identified as the primary repository. The self repository should instead always be identified as primary repository (if it was checked out).
I would have already fixed the bug and have already created a pull request to the master branch of this repository: https://github.com/microsoft/azure-pipelines-agent/pull/4217 The pull request needs to be reviewed and accepted.
This bug leads to the following wrong behaviours
It is always the repository url of the first repository checked out (instead of the self repository) that gets stored in the repositoryUrl field of the SourceFolder.json configuration file of a pipeline. For example... This:
checkout: self
checkout: MyRepo2
checkout: MyRepo2
checkout: self
The Build.Repository.LocalPath build variable should (according to the code in the BuildJobExtension.IsCheckoutToCustomPath method) always point to the path of the self repository if a path was defined during checkout, except if it's the default path (say, "s/MyRepo1" for a repository named MyRepo1). That's exactly the case if you check the self repository out first (instead of second or so). And also as soon as you define a path in the checkout step other than its default path, Build.Repository.LocalPath will point to that path. Though if you specifically define the path of the self repository to be the default path (again say "path: s/MyRepo1") and it is NOT the first one being checked out in a multi-checkout szenario, the Build.Repository.LocalPath build variable is suddenly pointing to the path of the self repository (so "s/MyRepo1" in this example). This is inconsistent behaviour, with the value of the Build.Repository.LocalPath build variable being dependent on the checkout position of the self repository in a multi-checkout scenario if (and only if) the default path for the self repository was specified. For example, if the name of the self repository is "MyRepo1" and the name of the MyRepo2 repository is "MyRepo2" then... This:
checkout: self path: s/MyRepo1
checkout: MyRepo2 path: s/MyRepo2
checkout: MyRepo2 path: s/MyRepo2
checkout: self path: s/MyRepo1
If you check the self repository out first and to another path than its default path, Build.Repository.LocalPath will point to that path, as expected. But if you then changed the self repository to be the second repository being checked out and let it now specifically check out to the default path (say "s/MyRepo1") by specifying that path during the checkout step, it then doesn't update the Build.Repository.LocalPath variable (on its first run) which is still pointing to the old path (which doesn't even exist any more since the repository was moved). It seems to correct that path on the next run though. For example, if the name of the self repository is "MyRepo1" and the name of the MyRepo2 repository is "MyRepo2" then... This:
checkout: self path: s/CustomPath
checkout: MyRepo2 path: s/MyRepo2
checkout: MyRepo2 path: s/MyRepo2
checkout: self path: s/MyRepo1
Agent Version and Platform
Agent Version: v2.189.0 (latest release, bug is in code of current master branch) and below OS of the machine running the agent: Windows (but should be OS independent)
Azure DevOps Type and Version
dev.azure.com and on-premises Azure DevOps Server 2020 onwards. Bug is in agent, not Azure DevOps Server, therefore the bug is independent of the server version or type. However, Azure DevOps Server 2019 and below doesn't allow a multi checkout scenario yet and will therefore not be able to recreate this issue.