代码之家  ›  专栏  ›  技术社区  ›  Ole Albers

在Azure DevOps管道中找不到上一步骤中的文件

  •  0
  • Ole Albers  · 技术社区  · 5 年前

    在管道中,我有两个不同的步骤。第一个生成一些文件,第二个应该将这些文件作为输入。

    该管道的Yaml如下:

    name: myscript
    stages:
    - stage: Tes/t
    displayName: owasp-test
    jobs:
    
    - job: owasp_test
      displayName: run beasic checks for site
      pool:
        name: default
        demands: Agent.OS -equals Windows_NT
    
      steps:
    
      - task: DotNetCoreCLI@2
        inputs:
          command: 'build'
          projects: '**/*.sln'
      - task: dependency-check-build-task@5
        inputs:
          projectName: 'DependencyCheck'
          scanPath: '**/*.dll'
          format: 'JUNIT'
      - task: PublishTestResults@2
        inputs:
          testResultsFormat: 'JUnit'
          testResultsFiles: '**/*-junit.xml'
    

    这个 dependency-check-build-task 返回XML文件:

    File upload succeed.
    Upload 'P:\Azure-Pipelines-Agent\_work\2\TestResults\dependency-check\dependency-check-junit.xml' to file container: '#/11589616/dependency-check'
    Associated artifact 53031 with build 21497
    

    以下步骤( PublishTestResults )应该拿走那份文件但是回来了

    ##[warning]No test result files matching **/*-junit.xml were found.
    

    相反。在管道运行之后,我可以在工件中看到该文件。

    0 回复  |  直到 5 年前
        1
  •  2
  •   Krzysztof Madej    5 年前

    这是因为你的报告是写给 Common.TestResultsDirectory 哪个是 c:\agent_work\1\TestResults (对于Microsoft托管代理),并在中发布测试任务 System.DefaultWorkingDirectory 哪个是 c:\agent_work\1\s

    请尝试:

      - task: PublishTestResults@2
        inputs:
          testResultsFormat: 'JUnit'
          testResultsFiles: '**/*-junit.xml'
          searchFolder: '$(Common.TestResultsDirectory)'