Total newbie with gitlab-runner, very confused with the shell executor. Please help!

Dear Gitlab gurus,

My .gitlab-ci.yml file below will highlight my confusion.

job1:
  script:
    - export TESTDIR=/opt/test_sans_rewrite
    - gitlab-runner run -c $TESDIR/config.toml -d $TESTDIR -u gitlab-runner
     - virtualenv -p $(which python2) testenv
    - source testenv/bin/activate
    - pip install -u requirements.txt
    - pytest -s -v tests

My goals:

  • clone and test my gitlab project under directory /opt/test_sans_rewrite (I gave write permissions for all)
  • the user to carry out the tests is gitlab-runner
  • runner configuration file is located in /opt/test_sans_rewrite/config.toml
  • create a python virtual environment where to run the tests.

I start the runner service in my local machine with sudo gitlab-runner restart. How can this service perform all my goals?

The contents of file /opt/test_sans_rewrite/config.toml

concurrent = 1
check_interval = 0

[[runners]]
  name = "sans_rewrite"
  url = "https://code-int.ornl.gov"
  token = "801bd1341a4bb7a42c0b6f43e9ffc8"
  executor = "shell"
  shell = "bash"
  [runners.cache]

Hi,

I am also working with shell executor.

I do not understand your problem. Is the runner running or not? Where the process get stuck?

Hi mrkintaro,

First thanks for replying. Your question made me revisit the registering process :slight_smile: so I registered a runner using sudo gitlab-runner register and followed all the steps. Then I did sudo gitlab-runner restart and then sudo gitlab-runner list with this outcome:

Listing configured runners                          ConfigFile=/etc/gitlab-runner/config.toml
sans_rewrite_shell_executor                         Executor=shell Token=5feb62ea59a2afaafce12af66136ba URL=https://code-int.ornl.gov

So the configuration file is listed under /etc/gitlab-runner, I wanted it to be under /opt/test_sans_rewrite but for the sake of simplicity I guess I’ll have to leave it under the “default” location.

Now, when the server clones the repository, where in the filesystem is it cloned? I want the server to clone within directory /opt/test_sans_rewrite. How do I achieve this?

Hi,

You have to play with the option builds_dir.

https://docs.gitlab.com/runner/configuration/advanced-configuration.html

Thanks, I set builds_dir = /opt/test_sans_rewrite and the project ended up being cloned unto /opt/test_sans_rewrite/5feb62ea/0/rhf/sans-rewrite.
This directory is persistent when testing different commits, which is OK as long as the commits belong to the same branch. I have to check if the directory is the same when testing different branches.