3

My Azure DevOps pipeline currently creates the path "C:\Agent-xyz_work\23\s..." for keeping the build output that will be used in the sub-project builds. Is there a way to set the build folder as just "C:" or "C:\w" etc? I need this because there is a custom build action by one of my third-party Wix toolsets that truncates the path when it gets too long. To keep it short, I want to keep the path as short as possible.

3 Answers3

2

You can change the value of the pre-defined variables.

For classic release pipeline:

Variables: enter image description here

Task:

enter image description here

Logs:

enter image description here

The list of pre-defined variables can be found here

Tejas Nagchandi
  • 442
  • 4
  • 11
1

The agent's working directory is configured when the agent is installed, and cannot be altered at runtime:

Agent setup
--work <workDirectory> - work directory where job data is stored. Defaults to _work under the root of the agent directory. The work directory is owned by a given agent and should not be shared between multiple agents.

I suggest you halt and reconfigure your agent with the working directory of your choice.

Vince Bowdren
  • 8,326
  • 3
  • 31
  • 56
0

The agent installed directory as stated from the predefined variables is:

Agent.HomeDirectory: c:\agent

The agent working directory is

Agent.WorkFolder : c:\agent_work

Inside this folder (C:\agent\work\builID), you can locate some subfolders:

  • a -> artifacts
  • b -> build directory
  • s -> source directory

You could use a powershell script and copy any artifacts or build outputs on the folder you want.

Powershell example:

$destinationFolder = "C:\myfolder"
$sourcesDirectory = "$(Build.ArtifactStagingDirectory)\result"
robocopy $sourcesDirectory $destinationFolder /im /e

https://learn.microsoft.com/en-us/azure/devops/pipelines/build/variables?view=azure-devops&tabs=yaml

GeralexGR
  • 2,973
  • 6
  • 24
  • 33
  • Thank you for the comment. If I set the variables before running the pipeline, the build output states that it is still using "C:\Agent-xyz_work\23\s...". Am I making any mistake here? – Arun Prakash Nagendran Dec 22 '21 at 09:41
  • I am not sure if those values can be overridden on runtime. You can set the agent working directory when you configure your custom agent. For the agent pool that Azure provides I am not sure if you can change the default values. That's why I proposed to copy any files you need from the working directory to your requested one. – GeralexGR Dec 22 '21 at 09:52
  • Thank you @GeralexGR. I do not have access to the agent pool. Another team maintains it. Then I guess I cannot override and resort to your other idea of copying things – Arun Prakash Nagendran Dec 22 '21 at 10:05