Azure Pipelines第二份工作找不到第一份工作的结果 [英] Azure Pipelines second job does not find results of first job

查看:67
本文介绍了Azure Pipelines第二份工作找不到第一份工作的结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始使用azure-pipelines.yml

I am getting started with azure-pipelines.yml

我希望在同一阶段有2个工作。

I wanted to have 2 jobs within the same stage. One to build a solution and the other to run unit tests.

问题是第二个作业执行了脚本步骤,但找不到文件夹释放上一个应该已创建:

The problem is that the second job executed a script step and it does not find a folder Release that the previous one should have created:

trigger:
- master

pool:
  vmImage: 'ubuntu-18.04'

stages:
- stage: CI
  jobs:
  - job: Build
    steps:
    - task: NuGetAuthenticate@0
    - script: dotnet restore --no-cache --force
    - script: dotnet build --configuration Release --no-restore
  - job: UnitTests
    dependsOn: Build
    steps:
    - script: dotnet vstest test/*UnitTests/bin/Release/**/*UnitTests.dll

但是,如果我在同一作业中添加所有步骤,那么它会起作用:

However if I add all the steps within the same job it works:

trigger:
- master

pool:
  vmImage: 'ubuntu-18.04'

stages:
- stage: CI
  jobs:
  - job: Build
    steps:
    - task: NuGetAuthenticate@0
    - script: dotnet restore --no-cache --force
    - script: dotnet build --configuration Release --no-restore
    - script: dotnet vstest test/*UnitTests/bin/Release/**/*UnitTests.dll

我找不到答案关于为什么一个依赖作业无法在文件系统上找到上一个文件夹生成的文件夹的信息。任何解释或澄清的链接将不胜感激。

I cannot find an answer on why a dependent job cannot find on the file system the folders that a previous one has generated. Any explanation or link to something that clarifies that would be much appreciated.

我过去曾经使用过gitlab,虽然我不这样做,但我不记得有类似的行为知道它是否具有作业的概念与步骤不同。

I have used gitlab in the past and I don't recall a similar behavior although I don't know whether it had the concept of job as a different thing to steps.

推荐答案

您缺少的关键要素是作业在独立的代理(独立的计算机)上运行,并且没有任何类型的共享文件系统。

The key element that you are missing is that jobs run on independent agents (separate computers) and do not have any kind of shared filesystem.

https://docs.microsoft.com/zh-cn/azure/devops/pipelines/process / phases?view = azure-devops& tabs = yaml

在一个作业中创建的任何要在从属作业中可用的文件都必须明确阶段(在作业 A中),然后显式下载(在作业 B中)。

Any files created in one job that you want to make available on a dependent job must be explicitly staged (in job 'A') and then explicitly downloaded (in job 'B').

请参见发布:

https://docs.microsoft.com/zh-CN/azure/devops/pipelines/tasks/utility/publish -build-artifacts?view = azure-devops

并下载:

https:// docs .microsoft.com / en-us / azure / devops / pipelines / tasks / utility / download-build-artifacts?view = azure-devops

这篇关于Azure Pipelines第二份工作找不到第一份工作的结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆