我们有一个单独的源代码存储库,如果下载的话大约是2.8 if。我们有4个自托管代理和100多个构建管道。因此,下载每个构建/代理的完整源代码是不可行的。
我采用的方法是禁用这些管道的签出,然后运行命令行脚本来执行Git稀疏签出。然而,这需要大约15分钟才能获得大约100MB的源代码。
我们使用的是自托管Linux代理。
steps:
- checkout: none
- task: CmdLine@2
displayName: "Project Specific Checkout"
inputs:
script: |
cd $(Build.SourcesDirectory)
git init
git config --global user.email ""
git config --global user.name ""
git config --global core.sparsecheckout true
echo STARS/Source/A/ >> .git/info/sparse-checkout
echo STARS/Source/B/ >> .git/info/sparse-checkout
echo STARS/Source/C/ >> .git/info/sparse-checkout
git remote rm origin
git remote add origin https://service:$(Service.Account.Personal.Access.Token)@dev.azure.com/Organization/Project/_git/STARS
git reset --hard
git pull origin $(Build.SourceBranch)有没有什么地方我做错了,导致它花了这么长时间来提取这些数据。
发布于 2021-04-19 11:04:07
1.由于您使用的是自托管代理,因此您可以转到代理机器,手动运行git命令,看看是否会获得相同的性能。
2.将变量system.debug设置为true,以检查哪个命令耗时较多。
3.您可以在checkout步骤中指定path,而不是Git稀疏签出:
steps:
- checkout: self | none | repository name # self represents the repo where the initial Pipelines YAML file was found
clean: boolean # if true, run `execute git clean -ffdx && git reset --hard HEAD` before fetching
fetchDepth: number # the depth of commits to ask Git to fetch; defaults to no limit
lfs: boolean # whether to download Git-LFS files; defaults to false
submodules: true | recursive # set to 'true' for a single level of submodules or 'recursive' to get submodules of submodules; defaults to not checking out submodules
path: string # path to check out source code, relative to the agent's build directory (e.g. \_work\1); defaults to a directory called `s`
persistCredentials: boolean # if 'true', leave the OAuth token in the Git config after the initial fetch; defaults to false4.由于您在自托管代理上运行管道,因此默认情况下,在两次连续运行之间不会清除任何子目录。因此,您可以进行增量构建和部署,前提是实现的任务能够利用这一点。因此您可以将清理选项设置为false。
https://stackoverflow.com/questions/67121806
复制相似问题