-1

I want to run py.test within the root of my repository(it runs fine when locally)

I have already set my environment variables for Python and Git (they work fine), and my CI runner connects with my gitlab repo. However, when a build is triggered I get this message:

gitlab-ci-multi-runner 1.3.1 (4911137)
Using Shell executor...
Running on XXXXXX...

Fetching changes...

HEAD is now at 1aa2135 Update .gitlab-ci.yml
Checking out 1aa21352 as cirunner...

$ py.test

'py.test' is not recognized as an internal or external command,

operable program or batch file.

ERROR: Build failed: exit status 9009

Why would the Shell Executor not recognize Python/py.test ?
This is on Windows Server 2012.

EDIT: I want to run unit tests with py.test everytime I push to remote

mugizico
  • 11
  • 2
  • 8
  • I'm confused, what are you trying to accomplish, is this a python script that you're trying to run? – 13aal Jun 28 '16 at 17:18
  • I just want to run unit tests(with py.test) on my project every time I push to remote – mugizico Jun 28 '16 at 17:31
  • 1
    is the thing that is trying to run the python script using the right directory? Maybe you need to specify a full path for `py.test` – Wolf Jun 28 '16 at 17:38
  • @mugizico have you tried using the `python` command? Is `python` in your env variables? Have you ever ran a `python` script on the machine your on? – 13aal Jun 28 '16 at 18:01
  • @Wolf that Worked!! thanks a bunch. I had to give it a full path to py.test so `C:\Users\myuser\python3\scripts\py.test` – mugizico Jun 28 '16 at 18:07
  • @13aal yes, yes, and yes if you read my question again, I already mentioned that running the script locally works just fine. the CI runner was the one causing the problem – mugizico Jun 28 '16 at 18:08

2 Answers2

4

I know it's one year late but might be useful for other people. You can set variables in your gitlab-ci.yml. Then you just have to set your PATH variable with the path to your python binaries like this :

variables:
  PATH: "C:\\Python27"

and then you can use the python command in any of your jobs

test:
  script:
    - python unittest.py
    - python regressiontest.py
    ...
Narthe
  • 492
  • 1
  • 4
  • 16
0

Almost similarly to this answer I just had to give the script in .gitlab-ci.yml a full path to py.test like so:

Script: - C:\Users\Admin\Python3\scripts\py.test

instead of

Script: - py.test

and it worked

Community
  • 1
  • 1
mugizico
  • 11
  • 2
  • 8