| ms.topic | include |
|---|---|
| ms.service | azure-devops-pipelines |
| ms.manager | mijacobs |
| ms.author | sdanie |
| ms.date | 01/28/2025 |
When pipeline jobs run on agents, a directory structure is created to store the source code, binaries, and artifacts.
The agent's home directory is the directory where the agent is installed. The directory is typically located:
- Microsoft-hosted agents:
C:\agents\<agent version>on Windows,/Users/runner/runners/<agent version>on macOS, and/home/vsts/agents/<agent version>on Linux. - Self-hosted agents:
C:\agenton Windows,Users/<username>/agent(~/agent) on macOS, and/home/vsts/agenton Linux.
The agent's work directory contains the workspace where the source and jobs output is stored. The work directory is typically located:
- Microsoft-hosted agent:
C:\aon Windows,/Users/runner/workon macOS, and/home/vsts/workon Linux. - Self-hosted agent:
C:\agent\_workon Windows,~/agent/workon macOS, and/home/agent/_workon Linux.
The work directory structure is:
- /work directory
- /1 build directory/pipeline workspace
- /s source/working directory
- /b binaries directory
- /a artifacts staging directory
- /TestResults Test results directory
| Directory | Description | Examples | Predefined variables |
|---|---|---|---|
| Agent home directory | Where the agent is installed. | Microsoft-hosted agent: Windows: C:\agents\3.248.0Linux: /home/vsts/agents/3.248.0macOS: /Users/runner/runners/3.248.0Self-hosted agent: Windows: C:\agentLinux: home/agent macOS: ~/agent |
Agent.HomeDirectory |
| Work directory | Where the agent stores the source code, binaries, and artifacts. | Microsoft-hosted agent: Windows: C:\aLinux: /home/vsts/workmacOS: /Users/runner/workSelf-hosted agent: Windows: C:\agent\_workLinux: /home/agent/_work macOS: ~/agent/work |
Agent.WorkFolderAgent.RootDirectory System.WorkFolder |
| Build directory or workspace | Where the pipeline job runs. | Microsoft-hosted agent: Windows: C:\a\1Linux: /home/vsts/work/1macOS: /Users/runner/work/1Self-hosted agent: Windows: C:\agent\_work\1Linux: /home/agent/_work/1 macOS: ~/agent/work/1 |
Agent.BuildDirectoryPipeline.Workspace |
s - Source or working directory |
Contains the source code checked out from the repository. If there are multiple checkout steps in your job, your source code is checked out into directories named after the repositories as a subfolder of s. |
Microsoft-hosted agent: Windows: C:\a\1\sLinux: /home/vsts/work/1/smacOS: /Users/runner/work/1/sSelf-hosted agent: Windows: C:\agent\_work\1\sLinux: /home/agent/_work/1/s macOS: ~/agent/work/1/s |
Build.SourcesDirectory Build.RepositoryLocalPathSystem.DefaultWorkingDirectory |
b - Binaries directory |
Contains the build outputs. | Microsoft-hosted agent: Windows: C:\a\1\bLinux: /home/vsts/work/1/bmacOS: /Users/runner/work/1/bSelf-hosted agent: Windows: C:\agent\_work\1\bLinux: /home/agent/_work/1/bmacOS: ~/agent/work/1/b |
Build.BinariesDirectory |
a - Artifacts staging directory |
Contains the build artifacts. Is cleaned between runs on self-hosted agents. | Microsoft-hosted agent: Windows: C:\a\1\aLinux: /home/vsts/work/1/amacOS: /Users/runner/work/1/aSelf-hosted agent: Windows: C:\agent\_work\1\aLinux: /home/agent/_work/1/a macOS: ~/agent/work/1/a |
Build.StagingDirectoryBuild.ArtifactStagingDirectory System.ArtifactsDirectory |
TestResults directory |
Contains the test results. Is cleaned between runs on self-hosted agents. | Microsoft-hosted agent: Windows: C:\a\1\TestResultsLinux: /home/vsts/work/1/TestResultsmacOS: /Users/runner/work/1/TestResultsSelf-hosted agent: Windows: C:\agent\_work\1\TestResultsLinux: /home/agent/_work/1/TestResults macOS: ~/agent/work/1/TestResults |
Common.TestResultsDirectory |
On Microsoft-hosted agents, a different agent is used on each run, so the work directory isn't retained between runs. On self-hosted agents, only the artifacts staging directory and test results directories are cleaned between runs by default. For more information about the workspace clean option, see Workspace.
For more information about predefined variables, see Predefined variables.