Home > OS >  Can't find installed modules in azure devops pipeline
Can't find installed modules in azure devops pipeline

Time:11-19

I'm building stage pipeline (env prp, tests, code). 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. Appreciate any hints how to make it working :)

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

CodePudding user response:

Different jobs and stages are capable of being executed on different agents in Azure Pipelines. 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.

  • Related