Why is pytest ending my pipeline?

I’m trying to run a pytest through a pipeline, and then run a few commands afterwards.
problem is that after the pytest run fails, the pipeline stops and exits, so i cannot perform command such as upload artifact of test report.
im using the shared gitlab runner

these are the logs of the job, as u see the test fails and then immediatly exits, the command ‘ls’ is not executed.

image: selenium/standalone-chrome:114.0.5735.133-chromedriver-114.0.5735.90

- install_package

  stage: install_package
  allow_failure: true

    - sudo apt-get update && sudo apt-get install python3.8-distutils -y
    - sudo wget https://bootstrap.pypa.io/get-pip.py
    - sudo python3 get-pip.py
    - sudo pip3 install virtualenv
    - sudo python3 -m virtualenv venv
    - source venv/bin/activate
    - sudo python3 -m pip install --upgrade pip
    - sudo pip3 install -r requirements.txt
    - sudo pip3 install dcentralab-qa-infra-automation==1.2.1
    - sudo pip3 install pytest
    - cd tests
    - sudo python3 -m pytest -v --html=report.html
    - ls
      - tests/report.html
      - report.html

That is expected, the job is stopped after first executed command’s exit code is > 0

how would i save the report file generated by pytest if the job immediatly stops and deletes all files?

The artifacts should be uploaded in any case. If the job abruptly exits there is something wrong and I suggest to look in GitLab Runner logs what’s happening.

I’m using gitlab’s shared runner, so i cannot access the runner


While troubleshooting this you might try to use when:on_failure or when:always to force whatever job artifacts did get created to upload.

I hope this helps.

-James H, GitLab Product Manager, Analyze:Product Analytics


that’s whats missing, thank you!

Thanks @jheimbuck_gl I missed that :slight_smile: I’ll just add (in case it’s not clear for anyone finding this) that it needs to be set on the artifacts.

    when: always
      - tests/report.html
      - report.html
1 Like