Reputation: 4303
So, I have a build stage and after a test and a deploy stage. Now I read about the artifact and saving the built files in there. But the problem is that the project is really big (.net) so the built files are +1GB. So the artifact didn't really work and was painfully slow.
Is there another way that I can skip building every step?
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
Upvotes: 0
Views: 88
Reputation: 103
You can use shell runner
for your stages (as far as i can see you are already using it).
Save build 'artifacts' directly on your server in folder with name something like commit sha or just 'build'. In this case you should add GIT_STRATEGY: none
for test and deploy stages (as you don't need to copy the repository after build). If you want to deploy to another server, you can use gitlab artifacts or use your own file-server to store builds and then copy from, or copy files to your production server directly from build server.
There is a need for adding 'clean' stage and free space from build files (or just clean folder on build stage)
Upvotes: 1