Gitlab 运行程序使用依赖作业中的构建文件

问题描述 投票:0回答:1

所以,我有一个构建阶段,然后是测试和部署阶段。 现在我了解了该工件并将构建的文件保存在其中。但问题是该项目非常大(.net),因此构建的文件有+1GB。所以这个神器并没有真正发挥作用,而且速度慢得令人痛苦。

还有另一种方法可以跳过构建的每一步吗?

stages:
  - build
  - test
  - deploy
  
build:
  stage: build
  script:
  - '& Write-Host "Restoring release build..."'
  - '& $env:NUGET restore "$env:SOLUTION.sln"'
  - '& Write-Host "Starting release build..."'
  - '& $env:MSBUILD /consoleloggerparameters:Summary /verbosity:quiet /maxcpucount /nologo /property:Configuration=Release /p:AllowUnsafeBlocks=true /nr:false "$env:SOLUTION.sln"'
  cache:
    paths:
      - Project/packages/
  tags:
    - windows
      
test:unit:
  stage: test
  script:
  - '& Write-Host "Running unit tests..."'
  - '& $env:NUGET restore "$env:SOLUTION.sln"'
  - '& $env:MSBUILD /consoleloggerparameters:Summary /verbosity:quiet /maxcpucount /nologo /p:Configuration=Release /p:PreBuildEvent= /p:PostBuildEvent= "$env:UNITTEST_PROJECT\$env:UNITTEST_PROJECT.csproj"'
  - '& $env:NUNIT ".\$env:UNITTEST\$env:UNITTEST_PROJECT.dll"'
  dependencies: 
    - build
  cache:
    paths:
      - Project/packages/
  tags:
    - windows
    
test:integration:
  stage: test
  script:
  - '& Write-Host "Running integration tests..."'
  - '& $env:NUGET restore "$env:SOLUTION.sln"'
  - '& $env:MSBUILD /consoleloggerparameters:Summary /verbosity:quiet /maxcpucount /nologo /p:Configuration=Release /p:PreBuildEvent= /p:PostBuildEvent= "$env:INTEGRATIONTEST_PROJECT\$env:INTEGRATIONTEST_PROJECT.csproj"'
##  - '& $env:NUNIT ".\$env:INTEGRATIONTEST\$env:INTEGRATIONTEST_PROJECT.dll"'
  dependencies: 
    - build
  cache:
    paths:
      - Project/packages/
  only:
    - triggers
    - schedules
    - tags
    - master
  tags:
    - windows
    
deploy:
  stage: deploy
  script:
  - '& Write-Host "Restoring release build..."'
  - '& $env:NUGET restore "$env:SOLUTION.sln"'
  - '& Write-Host "Starting release build..."'
  - '& $env:MSBUILD /consoleloggerparameters:Summary /verbosity:quiet /maxcpucount /nologo /property:Configuration=Release /p:AllowUnsafeBlocks=true /nr:false "$env:SOLUTION.sln"'
  - '& echo deploy'
  dependencies: 
    - build
    - test:unit
    - test:integration
  environment:
    name: production
  only:
    - tags
  tags:
    - windows
.net gitlab gitlab-ci-runner
1个回答
1
投票

您可以在您的阶段中使用

shell runner
(据我所知您已经在使用它了)。

将构建“artifacts”直接保存在服务器上的文件夹中,名称类似于 commit sha 或只是“build”。在这种情况下,您应该为测试和部署阶段添加

GIT_STRATEGY: none
(因为您不需要在构建后复制存储库)。如果您想部署到另一台服务器,您可以使用 gitlab 工件或使用您自己的文件服务器来存储构建,然后直接从构建服务器复制文件或将文件复制到生产服务器。

需要添加“干净”阶段和构建文件的可用空间(或者只是构建阶段上的干净文件夹)

© www.soinside.com 2019 - 2024. All rights reserved.