what pipeline variable is this path?
i’m hunting for the environment variable for this value
i’ve tried $(Build.SourcesDirectory)
and $(Agent.BuildDirectory)
these all come up in C drive, is there a source of output for all the pipeline environment variables per run?
resources:
repositories:
- repository: self
type: git
ref: refs/heads/master
...
steps:
- checkout: self
...
- task: PowerShell@2
displayName: Display Build Dir
inputs:
targetType: 'inline'
script: 'Write-Host "Build Directory Location: `"$(Agent.BuildDirectory)`""'
- task: NuGetCommand@2
displayName: NuGet restore
inputs:
solution: '$(BuildParameters.solution)'
selectOrConfig: config
nugetConfigPath: '$(Agent.BuildDirectory)/src/tree0/nuget.config'
5
The value of predefined variable “Agent.BuildDirectory
” is the local path on the agent where a pipeline is working in. The predefined variable “Pipeline.Workspace
” also has the same value.
The “Build.SourcesDirectory
” is a Azure Pipelines predefined variable, and its value is the local path on the agent where your source code files are downloaded. The predefined variables “Build.Repository.LocalPath
” and “System.DefaultWorkingDirectory
” also have the same value.
The “Build.SourcesDirectory
” is a subdirectory under “Agent.BuildDirectory
“.
For example:
There is an Windows agent named Win11-01
, and its installation directory on the agent machine is “E:VstsAgentsWin11_01
“, when running jobs using this agent, you might need to use the following predefined variables:
-
Agent.WorkFolder
: The working directory for this agent (E:VstsAgentsWin11_01_work
). It contains the working directories for all jobs run on this agent. -
Agent.BuildDirectory
: The working directory for each pipeline which has jobs run on this agent (E:VstsAgentsWin11_01_work<number>
). The<number>
folder will be named as1
,2
,3
,4
, etc.. which are automatically generated for each pipeline by sequential. For example,E:VstsAgentsWin11_01_work1
. -
Pipeline.Workspace
: Same asAgent.BuildDirectory
. -
Build.SourcesDirectory
: The directory where the source code files are downloaded into (E:VstsAgentsWin11_01_work<number>s
). This is the default directory that the checkout task will put the downloaded files into. On the checkout task, you can use thepath
option to specify a different directory.- When you set the job to check out just one repository, the content of the repository will be directly put into this directory.
- When you set the job to check out multiple repositories, the content of each repository will be put into the directory “
E:VstsAgentsWin11_01_work<number>s<repository-name>
“.
-
Build.Repository.LocalPath
andSystem.DefaultWorkingDirectory
: Same asBuild.SourcesDirectory
.
For more predefined variables in Azure Pipelines, you can see the documentation “Use predefined variables“.
idk why but using NugetCommand@2
with 'restore'
command on this windows agent uses back slashes . There was no error informing me of this. I changed the slashes and it started working.
despite the docs stating elsewise, see: slash documentation pipeline and seeing no contrary info in the task documentation: path variable doc in NugetCommand@2 i was left to trial and error (not really, a coworker suggested it but I dismissed the advice after reading the docs, silly me)
the code WAS in C drive despite the output of the checkout task stating elsewise. How did I find this out. I ran a recursive directory output that showed all the files.