简体   繁体   English

自托管 azure 代理 - 如何配置管道以共享相同的构建文件夹

[英]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 构建代理中遵循这种机制:

  • Daily check-ins were built to c:\work\tfs\ (taking about 5 minutes)每日签到建于 c:\work\tfs\(大约需要 5 分钟)
  • Each night a batch file would run that did the same build to those folders, using the same sources (they were already 'latest' from the CI build), and build the installers.每晚都会运行一个批处理文件,对这些文件夹执行相同的构建,使用相同的源(它们已经是 CI 构建中的“最新”),并构建安装程序。 Copy files to a network location, and send an email to the team detailing the build success/failures.将文件复制到网络位置,并将 email 发送给团队,详细说明构建成功/失败。 (Taking about 40 minutes) (大约需要 40 分钟)

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.

相关问题 有没有办法连接和查看Azure托管的自托管代理中的文件 - Is there a way to connect and view the files in a self Hosted Agent of Azure pipelines 使用不正确版本的 MSBuild 的自托管代理(用于 Azure 管道) - Self-hosted agent (for Azure pipelines) using incorrect version of MSBuild 如何在 Azure 云中使用自托管代理 - How to use an Self hosted agent in Azure Cloud azure 管道如何从 jenkins 服务器触发构建并将文件从自托管 linux 代理复制到托管代理并在托管代理上构建 - azure pipeline how to trigger build from jenkins server and copy files from with self-hosted linux agent to hosted agent and build on hosted agent 在 azure 构建管道中,一旦推送自托管代理,如何清理 docker 图像(作为管道的一部分创建)? - In the azure build pipeline, how to cleanup the docker images (created as part of the pipeline) from self hosted agent once it is pushed? Azure 管道,自托管代理,我可以使用脚本中的 zip 实用程序吗 - Azure pipelines, Self-hosted agent, can I use a zip utility from scripts Azure 自托管代理:运行超过 1 个构建代理时,此代理的会话已存在 - Azure Self Hosted agent : A session for this agent already exists , when running more then 1 build agent 如何在自托管的 Windows 代理中安装 Liquibase? (Azure Devops 管道) - How to install Liquibase in a self hosted Windows agent ? (Azure Devops Pipeline) 用于运行 pytest 的 Azure 自托管代理 - Azure Self hosted agent to run pytest 在自托管代理上运行容器作业时 Azure DevOps YAML 构建失败 - Azure DevOps YAML build fail when running container jobs on self hosted agent
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM