As they are, I need to change the directory where my repository is cloned, in the documentation I saw that there is a variable Pipeline.Workspace but I can not change it, I'm working with a self-hosted agent
Asked
Active
Viewed 8,014 times
0
-
It's unclear as to what you are actually trying to do. Why do you need to change where the pipeline clones the repository? – Josh Gust Jul 22 '19 at 23:13
-
yeah, it looks like you think you've found a solution to a problem you are having, but you are probably wrong. can you state the actual problem – 4c74356b41 Jul 23 '19 at 05:35
1 Answers
3
Change Variable Pipeline.Workspace in Azure Devops
To change the the default work folder _work
that Azure Devops agents use when building a pipeline, you can open the hidden.agent
file in the installation directory of the private agent and change the workFolder
to the place you want:
{
"agentId": 9,
"agentName": "VsAgent1",
"poolId": 10,
"serverUrl": "https://dev.azure.com/MyXXXXOrganization/",
"workFolder": "_work"
}
As test, I use bash task to output the value of variable Pipeline.Workspace
with the command line echo $(Pipeline.Workspace)
:
The default value is C:\VS2017Agent\_work\14
:
Then I change the workFolder
from _work
to D:\\tfsagent\\_work
in the .agent
file and run the build pipeline again:
The changed value is D:\tfsagent\_work\1
:
Check the document How to change the TFS Agent _work folder for some more details.
Hope this helps.
-
Thanks for the information, I managed to change the working directory with .agent but I still need to change where the cloned repository is saved example of /opt /azure/1/s change it from 1 to go and build it leaving /opt/azure/go/build/ How would you declare that kind of variables, in .agent I have "workFolder": "/opt/azure/" – Wallys Alexander Morales Gonza Jul 24 '19 at 16:16
-
1@WallysAlexanderMoralesGonza, AFAIK, we could not change the working directory `C:\agent_work\1` to `C:\agent_work\2`. Because Each build definition goes into its own directory within the agent's working directory. This is intentional, cannot be changed, and should not be changed. The reason it behaves this way is to support the ability to build concurrently -- multiple running builds sharing the same copy of the repository are guaranteed to step on each other sooner or later. Check this: https://stackoverflow.com/questions/50030715/make-vsts-agent-use-the-same-working-directory-every-time – Leo Liu Jul 26 '19 at 10:49