首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在Azure管道期间执行Git稀疏结帐需要大约15分钟

在Azure管道期间执行Git稀疏结帐需要大约15分钟
EN

Stack Overflow用户
提问于 2021-04-16 16:34:22
回答 1查看 396关注 0票数 0

我们有一个单独的源代码存储库,如果下载的话大约是2.8 if。我们有4个自托管代理和100多个构建管道。因此,下载每个构建/代理的完整源代码是不可行的。

我采用的方法是禁用这些管道的签出,然后运行命令行脚本来执行Git稀疏签出。然而,这需要大约15分钟才能获得大约100MB的源代码。

我们使用的是自托管Linux代理。

代码语言:javascript
复制
        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)

有没有什么地方我做错了,导致它花了这么长时间来提取这些数据。

EN

回答 1

Stack Overflow用户

发布于 2021-04-19 11:04:07

1.由于您使用的是自托管代理,因此您可以转到代理机器,手动运行git命令,看看是否会获得相同的性能。

2.将变量system.debug设置为true,以检查哪个命令耗时较多。

3.您可以在checkout步骤中指定path,而不是Git稀疏签出:

代码语言:javascript
复制
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 false

https://docs.microsoft.com/en-us/azure/devops/pipelines/yaml-schema?view=azure-devops&tabs=schema%2Cparameter-schema#checkout

4.由于您在自托管代理上运行管道,因此默认情况下,在两次连续运行之间不会清除任何子目录。因此,您可以进行增量构建和部署,前提是实现的任务能够利用这一点。因此您可以将清理选项设置为false

https://docs.microsoft.com/en-us/azure/devops/pipelines/process/phases?view=azure-devops&tabs=yaml#workspace

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67121806

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档