简体   繁体   English

在同一项目中的管道之间下载工件 Gitlab ci

[英]download artifacts between pipelines in the same project Gitlab ci

I am currently running 2 jobs.我目前正在运行 2 个工作。 One running some test unit which generate a coverage.xml file from php based project and another which launch a sonarqube analysis based on that coverage file.一个运行一些测试单元,它从基于 php 的项目生成一个 coverage.xml 文件,另一个运行基于该覆盖文件的 sonarqube 分析。

Here is the gitlab-ci.yml:这是 gitlab-ci.yml:

stages:
  - tests
  - sonar
    tests:
      stage: "tests"
      image: some-image
      only:
        - merge_requests
      script:
         - script.sh
      artifacts:
        paths:
          - var/php/xml/coverage.xml
    
    sonarqube-scanner:
      stage: "sonar"
      only:
        - specific_branch
      image:
        name: sonarsource/sonar-scanner-cli:latest
      cache:
        key: ${CI_JOB_NAME}
        paths:
          - .sonar/cache
      script:
        - sonar-scanner -Dsonar.php.coverage.reportPaths=#with_some_parameters
      allow_failure: false
      dependencies:
        - tests

When i run those 2 jobs with the same only condition ( both with only condition set to a specific branch) the sonar job can retrieve the artefact without any problem当我以相同的唯一条件运行这 2 个作业时(都只将条件设置为特定分支),声纳作业可以毫无问题地检索人工制品

As soon as i put different only condition between those 2 jobs, which is only in merge requests for my unit test and only in a specific branch for my sonar scan.一旦我在这两个作业之间设置不同的唯一条件,这仅在我的单元测试的合并请求中,并且仅在我的声纳扫描的特定分支中。 In the case where the merge request is not in the same branch as the branch specify in the sonar only conditions.如果合并请求与仅声纳条件中指定的分支不在同一分支中。 the sonar job is not able to retrieve the artefact.声纳作业无法检索人工制品。

Is there any way to pass an artefact from one job to another that have different only conditions?有什么方法可以将人工制品从一项工作传递到另一项具有不同唯一条件的工作?

Thanks in advance提前致谢

Is there any way to pass an artefact from one job to another that have different only conditions?有没有办法将人工制品从一项工作传递到另一项具有不同条件的工作?

Actually the conditions itself do not matter, as long as they both evaluate to letting the job run.实际上,条件本身并不重要,只要它们都评估让作业运行即可。

In the case where the merge request is not in the same branch as the branch specify in the sonar only conditions.在合并请求与仅声纳条件中指定的分支不在同一分支中的情况下。 the sonar job is not able to retrieve the artefact.声纳工作无法检索人工制品。

If it's not the branch as specified in the only condition, the sonarqube-scanner job won't run actually… Are you sure that the sonarqube-scanner job is really triggered?如果不是only条件中指定的分支,那么sonarqube-scanner作业将不会真正运行……您确定sonarqube-scanner作业真的被触发了吗?

As long as the dependency's "only" clause will ALWAYS include the only clause of the dependent, it should run.只要依赖项的“唯一”子句始终包含依赖项的唯一子句,它就应该运行。 In other words, something like tests run on all merge requests and sonar only runs on some merge requests.换句话说,测试在所有合并请求上运行,声纳仅在某些合并请求上运行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM