如何解决Gitlab运行程序使用依赖作业的构建文件
因此,我处于构建阶段,经过测试和部署阶段。 现在,我了解了artifcat并将生成的文件保存在其中。但是问题是项目非常大(.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
解决方法
您可以在舞台上使用shell runner
(据我所知,您已经在使用它)。
将构建“工件”直接保存在服务器上的文件夹中,其名称类似于commit sha或“ build”。在这种情况下,您应该添加GIT_STRATEGY: none
来进行测试和部署阶段(因为在构建后无需复制存储库)。如果要部署到另一台服务器,则可以使用gitlab工件或使用自己的文件服务器来存储构建,然后直接从构建服务器复制或将文件复制到生产服务器。
需要从构建文件(或在构建阶段仅清理文件夹)中添加“清理”阶段和可用空间
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。