仅在VSTS发布管道中将更改下载到git repo [英] Only download changes to git repo in VSTS release pipeline

查看:64
本文介绍了仅在VSTS发布管道中将更改下载到git repo的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个VSTS发布管道,可以从git repo复制文件:

I have a VSTS release pipeline that copies files from a git repo:

这个git repo确实很大-大约1GB.每次触发发布时,VSTS代理都会下载git repo的全部内容.有没有一种方法可以将VSTS配置为仅将更改下载到此git repo,即在存储库上运行git pull?这样可以节省大量时间和带宽.

This git repo is really big - around 1GB in size. Every time I trigger a release, the VSTS agent downloads the entire contents of the git repo. Is there a way to configure VSTS to only download the changes to this git repo, i.e. run a git pull on the repository? This would save a lot of time and bandwidth.

推荐答案

有两种方法可以使下载工件步骤更加高效.

There are two ways can make the download artifacts step more efficient.

首先删除发布管道中的docker工件.然后在每个发布环境的开始处添加 PowerShell任务(第一个任务).

First delete the docker artifacts in the release pipeline. Then add PowerShell task instead (first task) at the beginning of each release environment.

然后下载仅用于更改的文件的PowerShell,如下所示:

And the PowerShell to download for the only changed files as below:

mkdir partrepo
cd partrepo
git init
git remote add up -f https://Personal%20Access%20Token:{PAT}@{account}.visualstudio.com/{project}/_git/{repo}
#Or you can use the new Azure devops url instead
$files=$(git diff up/master up/master~ --name-only)
echo "changed files: $files"
$t=$files -is [array]
if ($files -is [array])
{
  echo "multiple files updated"
  for ($i=0;$i -lt $files.Length; $i++)
  {
  $tfile=$files[$i]
  git checkout up/master -- $tfile
  }
}
else
{
  git checkout up/master -- $files
}

注意:由于默认情况下未选中标准错误失败"选项,因此可以使用PowerShell任务版本2.*.

Note: you can use the PowerShell task version 2.*, since the Fail on Standard Error option is deselected by default.

您还可以将浅提取深度指定为1,然后向下工件步骤将仅下载最新的提交.它将大大减少伪像的大小.

You can also specify the shallow fetch depth as 1, then the down artifact step will only download the latest commit. And it will reduce the artifact size sharply.

这篇关于仅在VSTS发布管道中将更改下载到git repo的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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