Azure Pipelines 中是否有“/home/vsts”的预定义变量?

Mar*_*icz 5 azure-devops azure-pipelines

我需要将文件缓存在/home/vsts/.cache/torch/.

主文件夹是否有预定义变量?

Mar*_*icz 8

不,不存在这样的变量。/home/vsts/work您可以使用路径和缓存之一$(System.WorkFolder)/../.cache/torch/

Ubuntu 代理的预定义变量值:

Agent.AcceptTeeEula             True              
Agent.BuildDirectory            /home/vsts/work/1               
Agent.HomeDirectory             /home/vsts/agents/2.181.2              
Agent.Id                        32   
Agent.JobName                   Job        
Agent.JobStatus                 Succeeded          
Agent.MachineName               fv-az160-540            
Agent.Name                      Azure Pipelines 2     
Agent.OS                        Linux   
Agent.OSArchitecture            X64               
Agent.RetainDefaultEncoding     false                      
Agent.ReadOnlyVariables         true                  
Agent.RootDirectory             /home/vsts/work              
Agent.TempDirectory             /home/vsts/work/_temp              
Agent.ToolsDirectory            /opt/hostedtoolcache               
Agent.Version                   2.181.2        
Agent.WorkFolder                /home/vsts/work           
Build.ArtifactStagingDirectory  /home/vsts/work/1/a                         
Build.BinariesDirectory         /home/vsts/work/1/b                  
Build.DefinitionName            FooBar
Build.SourceBranch              refs/heads/FOOBAR-123-caching
Build.SourceVersion             2b2c45223722fc7226eb23d752fc722bcdee2c54
Build.SourcesDirectory          /home/vsts/work/1/s                 
Build.StagingDirectory          /home/vsts/work/1/a                 
Common.TestResultsDirectory     /home/vsts/work/1/TestResults                      
Pipeline.Workspace              /home/vsts/work/1             
System.AccessToken              ***             
System.ArtifactsDirectory       /home/vsts/work/1/a                    
System.CollectionId             c02d3c7b-9d74-4532-aa21-abccdf07c888
System.Culture                  en-US         
System.DefaultWorkingDirectory  /home/vsts/work/1/s                         
System.DefinitionId             26              
System.EnableAccessToken        SecretVariable                   
System.HostType                 build          
System.JobAttempt               1            
System.JobId                    33f11733-54f2-5aa3-20dd-22fc7dcf5912
System.JobName                  __default         
System.PhaseAttempt             1              
System.PhaseDisplayName         Job                  
System.PhaseName                Job           
System.ServerType               Hosted            
System.StageAttempt             1              
System.StageName                __default           
System.TeamProject              Foo Bar
System.TeamProjectId            3337a4f6-1411-40aa-beeb-0c7d86b9ecba
System.WorkFolder               /home/vsts/work            
Task.DisplayName                print predefined variables
Run Code Online (Sandbox Code Playgroud)


dan*_*orn 5

如果“预定义变量”是指文档中指定的变量之一,则不是。

但是,如果您使用托管 Linux 代理,您可以简单地查看环境变量$HOME,该变量至少在您使用脚本时有效:它可能适合也可能不适合您的用例。

例子:

trigger:
- main

pool:
  vmImage: ubuntu-latest

steps:
  - script: echo $HOME
Run Code Online (Sandbox Code Playgroud)

脚本任务的输出是/home/vsts