Gitlab';存在';规则不考虑工件

Gitlab';存在';规则不考虑工件,gitlab,gitlab-ci,Gitlab,Gitlab Ci,我在一些Gitlab CI作业中遇到了问题,在这些作业中,我指定了一个规则,仅当出现错误时才运行 这是我的.gitlab ci.yml: stages: - build - test #Jobs build: stage: build script: - dotnet restore --no-cache --force - dotnet build --configuration Release --no-restore artifacts: pa

我在一些Gitlab CI作业中遇到了问题,在这些作业中,我指定了一个规则,仅当出现错误时才运行

这是我的
.gitlab ci.yml

stages:
  - build
  - test

#Jobs
build:
  stage: build
  script:
    - dotnet restore --no-cache --force
    - dotnet build --configuration Release --no-restore
  artifacts:
    paths:
    - test/
    expire_in: 1 week

unit_tests:
  stage: test
  script: dotnet vstest test/*UnitTests/bin/Release/**/*UnitTests.dll --Blame
  rules:
    - exists:
      - test/*UnitTests/bin/Release/**/*UnitTests.dll

integration_tests:
  stage: test
  script: dotnet vstest test/*IntegrationTests/bin/Release/**/*IntegrationTests.dll --Blame
  rules:
    - exists:
      - test/*IntegrationTests/bin/Release/**/*IntegrationTests.dll
我只想在
test/
文件夹中的bin下有
*UnitTests.dll
时运行
unitu测试
,只有在
test/
文件夹中的bin下也有
*IntegrationTests.dll
时运行
integration\u测试

问题是这两项工作都被完全忽略了。换句话说,Gitlab似乎在将
exists
评估为false,就好像它只是在管道开始时评估的,而不是在作业开始时评估的一样,但是这些路径是存在的,因为它们是在前一阶段生成的,并且工件是自动可用的

如果我删除
规则
单元测试
将成功运行,但
集成测试
将失败,因为在我的特定项目中没有集成测试

我试着用
更改
替换
存在的
,同样的问题

如何实现此有条件作业执行


更新1:我有一个难看的解决方法,但问题仍然存在,因为
存在
似乎是在管道的开头而不是作业的开头进行评估的,因此,与工件相关的任何内容都会被忽略

这个技巧之所以有效,是因为我总是假设,如果有一个
csproj
,那么作为构建阶段的结果,稍后将有一个
dll

stages:
  - build
  - test

build:
  stage: build
  script:
    - dotnet restore --no-cache --force
    - dotnet build --configuration Release --no-restore
  artifacts:
    paths:
    - test/
    expire_in: 1 week

unit_tests:
  stage: test
  script: dotnet vstest test/*UnitTests/bin/Release/**/*UnitTests.dll --Blame
  rules:
    - exists:
      - test/*UnitTests/*UnitTests.csproj

integration_tests:
  stage: test
  script: dotnet vstest test/*IntegrationTests/bin/Release/**/*IntegrationTests.dll --Blame
  rules:
    - exists:
      - test/*IntegrationTests/*IntegrationTests.csproj

在撰写本文时,GitLab似乎不支持在规则中使用工件文件。它不起作用


我自己的解决方法是删除条件规则,而是编写一个包装器脚本,首先检查文件的存在。

找到答案了吗?gitlab文档对于这是否会起作用还不清楚。