There is a runner that works when pushing, it must execute a script which is located on the server on which the gitlab itself is located.

The script looks like this:

#!/usr/bin/env bash forever stop "myproject" cd /myproject export NODE_PATH=. export NODE_ENV=qa export NODE_INIT_TARGET=build node --use_strict bin/init forever start -a --uid "myproject" --minUptime 20000 --spinSleepTime 20000 bin/start --use_strict 

those. it just has to run a js script that will first remove the process from forever.js (by stopping the application), assemble the front, then add the process to forever.js (start the application). So if you use your hands in the console to run, everything works. But the runner gives the following error:

 Running with gitlab-ci-multi-runner 1.10.4 (b32125f) Using Shell executor... Running on server... Fetching changes... HEAD is now at 5553b27 Merge branch 'dev' into 'master' Checking out ed68665c as dev... Skipping Git submodules setup $ /myproject/myScript.sh /myproject/myScript.sh: строка 3: forever: команда не найдена /myproject/myScript.sh: строка 11: node: команда не найдена /myproject/myScript.sh: строка 13: forever: команда не найдена ERROR: Build failed: exit status 1 

What could be the reason?

 root@server:/node_data/csgo-forecast/bin# env PATH=/home/sanu/.nvm/versions/node/v6.9.5/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin root@server:/node_data/csgo-forecast/bin# sudo -iu gitlab-runner bash -c set PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin 

    1 answer 1

    This means that the necessary dependencies are not installed or not available.

     /myproject/myScript.sh: строка 3: forever: команда не найдена /myproject/myScript.sh: строка 11: node: команда не найдена 

    Shell Runner works under the gitlab-runner . It seems that node and forever are not available to it. Perhaps, in the PATH there are no necessary directories - compare it with the PATH on the account under which you have successfully started everything manually. It is also possible that you need to run from under a privileged account.

    Read more: Running as unprivileged user

    (Yes, this is not the answer yet, but it is no longer included in the comment. I will supplement the answer as details become available.)

    • root@server:/node_data/csgo-forecast/bin# env PATH = / home / sanu / .nvm / versions / node / v6.9.5 / bin: / usr / local / sbin: / usr / local / bin: / usr / sbin: / usr / bin: / sbin: / bin root@server:/node_data/csgo-forecast/bin# sudo -iu gitlab-runner bash -c set PATH = / usr / local / sbin: / usr / local / bin: / usr / sbin: / usr / bin: / sbin: / bin I don’t understand where is the path to forever and node? - sanu0074
    • @ sanu0074 which forever; which node which forever; which node . Both lie somewhere in these paths. - Nick Volynkin
    • Most likely in /home/sanu/.nvm/versions/node/v6.9.5/bin - Nick Volynkin
    • I added to /home/gitlab-runner/.bashrc export NVM_DIR = "$ HOME / .nvm" [-s "$ NVM_DIR / nvm.sh"] && \. "$ NVM_DIR / nvm.sh" But this user's PATH has not changed. Tell me how to change the variable to the user gitlab-runner? - sanu0074
    • one
      @ sanu0074 Looks like I won't tell you further. We need to figure out how to do everything correctly with a shell runner - and I mostly worked with the docker runner. - Nick Volynkin