【发布时间】:2021-09-25 09:24:24
【问题描述】:
鉴于此示例,Gitlab 的 .Net CI 管道配置
image: mcr.microsoft.com/dotnet/sdk:5.0
stages:
- build
build:
stage: build
script:
- |
BUILD_WARNINGS_LOG_FILE="buildWarnings.log";
dotnet build -consoleloggerparameters:"Summary;Verbosity=normal" -m -p:"WarnLevel=5;EnforceCodeStyleInBuild=true" -t:"clean,build" -fl1 "/flp1:logFile=$BUILD_WARNINGS_LOG_FILE;warningsonly";
if [ $? -eq 0 ] && [ $(wc -l < $BUILD_WARNINGS_LOG_FILE) -gt 0 ]
then
# do stuff here
fi
管道因语法无效而失败。这是因为它不知道有多个 shell 命令要执行。
这个.sh 文件在我的本地机器上工作
#!/bin/bash
BUILD_WARNINGS_LOG_FILE="buildWarnings.log";
dotnet build --output build -consoleloggerparameters:"Summary;Verbosity=normal" -m -p:"WarnLevel=5;EnforceCodeStyleInBuild=true" -t:"clean,build" -fl1 "/flp1:logFile=$BUILD_WARNINGS_LOG_FILE;warningsonly";
if [ $? -eq 0 ] && [ $(wc -l < $BUILD_WARNINGS_LOG_FILE) -gt 0 ]
then
# do stuff here
fi
那么我怎样才能将它正确地嵌入到 Gitlab ci 阶段呢?
【问题讨论】:
标签: shell gitlab continuous-integration yaml gitlab-ci