简体   繁体   English

在 azure devops 管道中找不到已安装的模块

[英]Can't find installed modules in azure devops pipeline

I'm building stage pipeline (env prp, tests, code).我正在构建阶段管道(环境 prp、测试、代码)。 Currently have faced the blocker.目前已经面临拦截器。 Seems like each stage is kindda individual process.似乎每个阶段都是一个单独的过程。 My requirements.txt is being installed correctly but then test stage raises the ModuleNotFoundError.我的 requirements.txt 安装正确,但测试阶段引发 ModuleNotFoundError。 Appreciate any hints how to make it working:)感谢任何提示如何使它工作:)

yaml: yaml:

trigger: none
parameters:
  - name: "input_files"
    type: object
    default: ['a-rg', 't-rg', 'd-rg', 'p-rg']

stages:
  - stage: 'Env_prep'
    jobs:
      - job: "install_requirements"
        steps:
          - script: |
              python -m pip install --upgrade pip
              python -m pip install -r requirements.txt
  - stage: 'Tests'
    jobs:
      - job: 'Run_tests'
        steps:
          - script: |
              python -m pytest -v tests/variableGroups_tests.py

Different jobs and stages are capable of being executed on different agents in Azure Pipelines.不同的作业和阶段能够在 Azure 管道中的不同代理上执行。 In your case, the installation requirements are a direct prerequisite of the tests being run, so everything should be in one job:在您的情况下,安装要求是运行测试的直接先决条件,因此一切都应该在一项工作中完成:

trigger: none
parameters:
  - name: "input_files"
    type: object
    default: ['a-rg', 't-rg', 'd-rg', 'p-rg']

stages:
  - stage: Test
    jobs:
      - job:
        steps:
          - script: |
              python -m pip install --upgrade pip
              python -m pip install -r requirements.txt
            displayName: Install Required Components
          - script: |
              python -m pytest -v tests/variableGroups_tests.py
            displayName: Run Tests

Breaking those into separate script steps isn't even necessary unless you want the log output to be separate in the console.除非您希望日志 output 在控制台中分开,否则甚至不需要将它们分解为单独的脚本步骤。

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

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