Azure DevOps - 清理构建目录 [英] Azure DevOps - Clean build directory

查看:33
本文介绍了Azure DevOps - 清理构建目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

顺便提一下,我正在使用自托管代理来运行我的构建和发布管道.

Just to mention I am using a self-hosted agent for running my build and release pipelines.

问题是当我运行任何构建并且由于管道中的某些问题而失败时.来自远程的克隆分支位于 _work 目录中.第二次运行也选择了相同的工作目录,我已经从 agent _work 目录手动检查没有克隆新目录,我还可以从 Azure Pipeline 日志中验证它们使用的是相同的旧目录.

The problem is when I run any build and it failed due to some issues in the pipeline. The cloned branch from remote sits in the _work directory. The second run also picks up the same work directory, and I have checked manually from the agent _work directory no new directory was cloned and I can also verify from Azure Pipeline logs they are using the same old directory.

我暂时解决了这个问题,我进入旧目录(即/home/user/_work/13)并手动删除那13个目录然后azure将其捡起新文件夹说_work下的14,我可以远程查看最新的克隆代码.

What I did temporarily to solve this, I went into the old directory(i.e. /home/user/_work/13) and manually delete that 13 directories then azure pick it up the new folder say 14 under _work, and I could see the latest cloned code from the remote.

那么如何在发生任何故障时自动删除工作文件夹(代理构建目录,即 _work 下的 13/14).

So how to automatically delete the work folder(agent build directory i.e. 13/14 under _work) in case of any failure happen.

PS:当我的管道成功完成时,我已经有清理步骤,我在最后运行.另外,我正在编写基于 .yml 的管道.

PS: I already have cleanup steps in place when my pipeline complete with success, which I run at the end. Also, I am writing .yml based pipelines.

如果需要任何信息以便更好地理解,请告诉我.

Please let me know if any information is required for a better understanding.

推荐答案

Azure DevOps - 清理构建目录

Azure DevOps - Clean build directory

在 Get Source 选项卡上有一个 Clean 选项,它可以在运行构建之前对您的私有代理的工作目录执行不同类型的清理:

There is an Clean option on the Get Source tab, which could perform different kinds of cleaning of the working directory of your private agent before the build is run:

我们可以将该值设置为 true 以清理您的私人代理的工作目录.即使构建失败.

We could set the value to true to clean the working directory of your private agent. Even if the build is failed.

您可以查看文档 清理代理上的本地存储库 以获取更多详细信息.

You could check the document Clean the local repo on the agent for some more details.

更新:

但这适用于经典管道,我们没有任何标签我们只在 yml 管道中定义

But this is meant for the classic pipeline, do not we have any tag which we define in yml pipeline only

jobs:
- job: string  # name of the job (A-Z, a-z, 0-9, and underscore)
  ...
  workspace:
    clean: outputs | resources | all # what to clean up before the job runs

检查此文档 YAML 架构参考 了解详情.希望这会有所帮助.

Check this document YAML schema reference for some details. Hope this helps.

这篇关于Azure DevOps - 清理构建目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆