-
Notifications
You must be signed in to change notification settings - Fork 866
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added option to use a checkout path of any repository as the default working directory (System.DefaultWorkingDirectory) #3479
Added option to use a checkout path of any repository as the default working directory (System.DefaultWorkingDirectory) #3479
Conversation
…h of a checked out repository as the default working directory. Also added UnitTests for this new setting.
Hi, @echalone, thanks for your contribution. Steps to test these changes:
pool: <Self-Hosted Agent Pool>
resources:
repositories:
- repository: first
type: github
endpoint: <github-endpoint>
name: <github-username>/<first-repo>
- repository: second
type: github
endpoint: <github-endpoint>
name: <github-username>/<second-repo>
steps:
- task: Checkout@1
inputs:
repository: first
path: first/repo/custom/path
workspaceRepo: false
displayName: Checkout First Repo
- task: Checkout@1
inputs:
repository: second
path: second/repo/custom/path
workspaceRepo: true
displayName: Checkout Second Repo
- bash: |
echo ">>> Current working directory:"
pwd
echo ">>> Items in this directory:"
ls
displayName: Check Result |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, @echalone, I tested this PR. The workspaceRepo
option works properly, thanks.
thanks @DenisRumyantsev and you're welcome :) what's the next step? An approval by the microsoft/azure-pipelines-platform group? |
/azp run |
5453cda
to
f1c294b
Compare
awesome, thanks so much :) |
Synopsis
Added boolean option (using predefined option workspaceRepo) to checkout task to define the path of a checked out repository as the default working directory. The source path of the first checkout build step in a Yaml Pipeline that uses and sets the "workspaceRepo" option to true will become the path for the System.DefaultWorkingDirectory (instead of setting it to the the same value as the Build.SourcesDirectory). Also adapted the BuildJobExtension to use the value of the System.DefaultWorkingDirectory build variable, instead of the Build.SourcesDirectory build variable, for the "working directory" and resolve file paths to the path of the System.DefaultWorkingDirectory build variable. This is backwards compatible since if the pipeline is not using this new option then System.DefaultWorkingDirectory will just point to the same location as Build.SourcesDirectory does.
Scripts and executable files as well as file inputs to tasks will now resolve to the System.DefaultWorkingDirectory, which can now be adapted to be set to the checkout path of a desired repository if the default behaviour of it pointing to "\s" is not desired (important for pipelines checking out to a different location than the default path).
The feature request for this new option can be found here: #3484
Also added UnitTests for this new setting.
New boolean option
For now I've used the currently unused and undocumented checkout task option "workspaceRepo" as defined as field WorkspaceRepo in the Microsoft.TeamFoundation.DistributedTask.Pipelines.PipelineConstants.CheckoutTaskInputs class. If another (and differntly named) new field should be used this will need to be defined in the Microsoft.TeamFoundation.DistributedTask.Pipelines.PipelineConstants.CheckoutTaskInputs class first by Microsoft (it's not public code, I can't help there).
Important: No matter if this existing field is used or a new one, currently there exists NO such option in the Yaml pipeline checkout task syntax and after this new functionality has been added to the build agent (by accepting the pull request) Microsoft still needs to add the new option to the Yaml pipeline checkout task syntax (and its documentation) so it can actually be used in the checkout build step of Yaml pipelines! This, again, is not public code, so I can't help there.