Windows上的GitLab运行程序并处理& %ERRORLEVEL% [英] GitLab runner on Windows and dealing with & %ERRORLEVEL%
本文介绍了Windows上的GitLab运行程序并处理& %ERRORLEVEL%的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的.gitlab-ci.yml中,我试图使用findstr命令.
In my .gitlab-ci.yml, i am trying to use the findstr command.
findstr /c:"%SOLUTION_DIR%" gitlab.dif > founded.ref
如果该命令在gitlab.dif中与%SOLUTION_DIR%"不匹配,则将%ERRORLEVEL%设置为1.
This command set the %ERRORLEVEL% to 1 if it has no match of "%SOLUTION_DIR%" in gitlab.dif.
GitLab跑步者似乎将其解释为工作失败.
It seems like GitLab runner is interpreting this as a job failure.
ERROR: Job failed: exit status 1
有什么解决方法吗?
我的.gitlab-ci.yml文件
my .gitlab-ci.yml file
stages:
- check
- build
check_diff:
stage: check
script:
- git diff --name-only origin/develop...HEAD > _gitlab_diff.txt
- git diff --name-only HEAD~1 >> _gitlab_diff.txt
artifacts:
paths:
- _gitlab_diff.txt
only:
refs:
- merge_requests
- develop
.generic_build_job:
stage: build
dependencies:
- check_diff
before_script:
- findstr /c:"%SOLUTION_DIR%" "_gitlab_diff.txt" > _check_%SOLUTION_FILE%.txt
- for /f %%i in ("_check_%SOLUTION_FILE%.txt") do set size=%%~zi
- if %size% == 0 exit 0
- cd %SOLUTION_DIR%
script:
- '"%NUGET%" restore "%SOLUTION_FILE%"'
- '"%MSBUILD%" /consoleloggerparameters:ErrorsOnly /maxcpucount /nologo /property:Configuration=Release /verbosity:quiet "%SOLUTION_FILE%"'
only:
refs:
- merge_requests
- develop
MyApp1:
variables:
SOLUTION_DIR: "MyApp1/"
SOLUTION_FILE: "MyApp1.sln"
extends: .generic_build_job
only:
changes:
- MyApp1/*
MyApp2:
variables:
SOLUTION_DIR: "MyApp2/"
SOLUTION_FILE: "MyApp2.sln"
extends: .generic_build_job
only:
changes:
- MyApp2/*
推荐答案
我发现了使用批处理脚本的解决方法.
I found a workaround using a batch script.
这是我的skip.bat:
Here is my skip.bat :
findstr /c:%1 %2 >nul 2>&1
if not %errorlevel% == 0 exit 0
这篇关于Windows上的GitLab运行程序并处理& %ERRORLEVEL%的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文