How to input commands into Python InteractiveConsole when opened in Gitlab Runner

123 Views Asked by At

I am trying to perform an operation in Gitlab Runner using Python's InteractiveConsole. Below is the test case that I'm trying to implement. The last two lines of the before_script segment is what I want to run in the InteractiveConsole:

py_test:
        image: python:3.8.0-slim
        stage: test
        before_script:
                - pip install pytest-html
                - pip install -r requirements.txt
                - export FLASK_APP=app
                - flask shell
                - from app import db
                - db.create_all()
        script:
                - mkdir pytest_reports
                - pytest --html=pytest_reports/pytest_report.html
        artifacts:
                when: always
                paths:
                        - pytest_reports/

In the log file I can see the InteractiveConsole does open, but the pipeline skips right over it and tries to run the last two commands back in shell.

$ export FLASK_APP=app
$ flask shell
Python 3.8.0 (default, Nov 23 2019, 05:49:00) 
[GCC 8.3.0] on linux
App: app
Instance: /builds/placebo-me-please/employee-data-app/instance
>>> 
now exiting InteractiveConsole...

How can I write those two commands to the InteractiveConsole? I assume it has to be done with the $flask shell command.

0

There are 0 best solutions below