我有一个VSTS发布管道从git仓库复制文件:
这个git repo非常大 - 大约1GB。每次触发发布时,VSTS代理都会下载git repo的全部内容。有没有办法配置VSTS只下载对此git仓库的更改,即在存储库上运行git pull
?这将节省大量时间和带宽。
有两种方法可以使下载工件更有效。
首先删除发布管道中的docker工件。然后在每个发布环境的开头添加PowerShell任务(第一个任务)。
并且PowerShell下载了唯一更改的文件,如下所示:
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.*
,因为默认情况下取消选中“标准错误时失败”选项。
您还可以将浅提取深度指定为1,然后向下工件步骤将仅下载最新提交。它会大幅减少人工制品的尺寸。
我认为您正在寻找的是真正使用构建管道中的工件。以下是构建管道的YAML,它使用“发布工件”任务将README.md
文件发布为artifact
。
resources:
- repo: self
queue:
name: Hosted VS2017
steps:
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: drop'
inputs:
PathtoPublish: README.md
然后在发布管道中,您可以从构建管道中添加工件(请记住至少先构建一次!)。然后,此工件将在发布管道中可用。这是一个示例,我将复制文件任务添加到管道并使用工件;
总结一下;
git pull
。