gitlab - Gitlab CI 对发布或调试构建的依赖
问题描述
我正在学习 gitlab-runner 如何工作,并创建一个脚本来运行 Windows C# 项目的构建。
我在我的 shell 上设置了一个运行器并安装了所有需要的工具来构建,但现在我需要创建一个好的 .yml 脚本来运行。
我已经有一些代码,但我不知道是否可以有多个依赖项,比如 OR?
这就是我现在所拥有的:
variables:
PROJECT_LOCATION: "ProjectFolder"
PROJECT_NAME: "ProjectName"
before_script:
- echo "starting build for %PROJECT_NAME%"
- cd %PROJECT_LOCATION%
stages:
- build
- artifacts
- test
- deploy
build:debug:
stage: build
script:
- echo "Restoring NuGet Packages..."
- 'nuget restore "%PROJECT_NAME%.sln"'
- echo "Starting debug build..."
- 'msbuild /consoleloggerparameters:ErrorsOnly /maxcpucount /nologo /property:Configuration=Debug /verbosity:quiet /p:AllowUnsafeBlocks=true /nr:false "%PROJECT_NAME%.sln"'
except:
- master
tags:
- windows
build:release:
stage: build
script:
- echo "Restoring NuGet Packages..."
- 'nuget restore "%PROJECT_NAME%.sln"'
- echo "Starting release build..."
- 'msbuild /consoleloggerparameters:ErrorsOnly /maxcpucount /nologo /property:Configuration=Release /verbosity:quiet /p:AllowUnsafeBlocks=true /nr:false "%PROJECT_NAME%.sln"'
only:
- master
tags:
- windows
artifacts:
stage: artifacts
script:
- echo "Creating artifacts..."
dependencies:
- build
artifacts:
name: "Console"
paths:
- Project.Console/bin/
expire_in: 2 days
untracked: true
name: "Service"
paths:
- Project.Service/bin/
expire_in: 1 week
untracked: true
only:
- tags
- master
- schedules
tags:
- windows
test:unit:
stage: test
script:
- echo "Running tests..."
dependencies:
- build
tags:
- windows
test:integration:
stage: test
script:
- echo "Running integration tests..."
dependencies:
- build
only:
- tags
- master
- schedules
tags:
- windows
deploy:
stage: deploy
script:
- echo "Deploy to production..."
dependencies:
- build
environment:
name: production
only:
- tags
tags:
- windows
但是正如你所看到的,我给了它依赖构建,它不喜欢这样,因为我有 build:debug 和 build:release。有没有办法解决这个问题?
如果还有其他指示我需要牢记始终欢迎......(就像我说的我还在学习)
解决方案
I found the answer apparently you can have multiple dependencies and this is an or statement.
So for example:
artifacts:
stage: artifacts
script:
- echo "Creating artifacts..."
dependencies:
- build:debug
- build:release
artifacts:
name: "Console"
paths:
- Project.Console/bin/
expire_in: 2 days
untracked: true
name: "Service"
paths:
- Project.Service/bin/
expire_in: 1 week
untracked: true
only:
- tags
- master
- schedules
tags:
- windows
推荐阅读
- python - 如何从公会 discord.py 中的所有成员中删除多个角色
- python-3.x - 对于灰度到 rgb 问题,我应该使用哪个损失函数?
- sharepoint - SharePoint WebPart 上下文菜单进入 div(请参见图片)
- ios - 传入的 GameCenter 邀请不包含任何玩家
- excel - 如何使用后缀(k、m、g、uF、H 等)对电子值进行排序?
- memory-management - 分页和非连续内存分配
- python-3.x - 我如何计算一行中有多少个 1 或 0?
- python - 无法限制内存
- r - 我应该使用什么方法/模块对文本进行分类/分类?
- laravel - Laravel 和图像验证