0

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.

  • Why can't you put your python scripts in a file and run python script directly instead of using InteractiveConsole? Like `echo "flask shell" > temp.py` later `python3 temp.py` ?? – Prabhu Vignesh Rajagopal Nov 15 '22 at 19:56
  • I'm just repeating the steps that I had to do to get the app working on my local machine. (For context, this I'm taking a course on CI/CD development, so I did not create the app.) Is there a way to do what I'm asking, or do I have to implement the method you suggested? – placebo_me_please Nov 15 '22 at 22:21

0 Answers0