[英]Self hosted azure agent - how to configure pipelines to share the same build folder
We have a self-hosted build agent on an on-prem server.我们在本地服务器上有一个自托管的构建代理。
We typically have a large codebase, and in the past followed this mechanism with TFS2013 build agents:我们通常有一个庞大的代码库,过去在 TFS2013 构建代理中遵循这种机制:
The key thing there is that for the nightly build there would be no need to get the latest sources, and the disk space required wouldn't grow much.关键在于,对于每晚构建,不需要获取最新的资源,并且所需的磁盘空间不会增加太多。 Just by the installer sizes.
仅由安装程序尺寸决定。
To replicate this with Azure Devops, I created two pipelines.为了使用 Azure Devops 复制这一点,我创建了两个管道。 One pipeline that did the CI using MSBuild tasks in the classic editor- works great Another pipeline in the classic editor that runs our existing powershell script, scheduled at 9pm - works great
在经典编辑器中使用 MSBuild 任务执行 CI 的一个管道 - 效果很好 经典编辑器中的另一个管道运行我们现有的 powershell 脚本,安排在晚上 9 点 - 效果很好
However, even though my agent doesn't support parallel builds what's happening is that: The CI pipeline's folder is c:\work\1\ The Nightly build folder is c:\work\2\但是,即使我的代理不支持并行构建,正在发生的事情是: CI 管道的文件夹是 c:\work\1\ Nightly 构建文件夹是 c:\work\2\
This doubles the amount of disk space we need (10gb to 20gb) They are the same code files, just built differently.这使我们需要的磁盘空间量翻了一番(10gb 到 20gb)。它们是相同的代码文件,只是构建方式不同。
I have struggled to find a way to say to the agent "please use the same sources folder for all pipelines"我一直在努力寻找一种方式对代理说“请对所有管道使用相同的源文件夹”
What setting is this, as we have to pay our service provider for extra GB storage otherwise.这是什么设置,否则我们必须向服务提供商支付额外的 GB 存储空间。
Or do I need to change my classic pipelines into Yaml and somehow conditionally branch the build so it knows it's being scheduled and do something different?或者我是否需要将我的经典管道更改为 Yaml 并以某种方式有条件地分支构建,以便它知道它正在被安排并做一些不同的事情? Or maybe, stop using a Pipeline for the scheduled build, and use task scheduler in Windows as before?
或者,停止使用管道进行计划构建,并像以前一样在 Windows 中使用任务调度程序?
(I did try looking for the same question - I'm sure I can't be the only one). (我确实尝试寻找同样的问题 - 我确定我不能成为唯一的问题)。
There is "workingDirectory" directive available for running scripts in pipeline.有“workingDirectory”指令可用于在管道中运行脚本。 This link has details of this - https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/utility/command-line?view=azure-devops&tabs=yaml
此链接包含详细信息 - https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/utility/command-line?view=azure-devops&tabs=yaml
The number '1' '2'...'6' of work folder c:\work\1\
, c:\work\2\
... c:\work\6\
in your build agent which stands for a particular pipeline.工作文件夹的编号 '1' '2'...'6'
c:\work\1\
, c:\work\2\
... c:\work\6\
代表您的构建代理特定的管道。
Agent.BuildDirectory
Agent.BuildDirectory
The local path on the agent where all folders for a given build pipeline are created.
为给定构建管道创建所有文件夹的代理上的本地路径。 This variable has the same value as Pipeline.Workspace.
此变量与 Pipeline.Workspace 具有相同的值。 For example: /home/vsts/work/1
例如:/home/vsts/work/1
If you have two pipelines, there will also be two corresponding work folders.如果你有两个管道,也会有两个对应的工作文件夹。 It's an except behavior.
这是一种例外行为。 We could not configure pipelines to share the same build folde.
我们无法将管道配置为共享相同的构建文件夹。 This is by designed.
这是设计的。
If you need to use less disk space to save cost, afraid stop using a Pipeline for the scheduled build, and use task scheduler in Windows as before is a better way.如果您需要使用更少的磁盘空间来节省成本,害怕停止使用 Pipeline 进行计划构建,并像以前一样使用 Windows 中的任务调度程序是更好的方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.