1

I'm using gitlab runner on a mac mini server. While using user named "runner" I manage to use this command:

gsutil ls -l gs://tests/ |grep staging | sort -k 2 | tail -n 3| head -n 2 |awk '{print $3}' | gsutil -m cp -I .

I manage to get the files, but while using the same command in gitlab-ci.yml like this:

stages:
  - test
test:
  stage: test
  when: always
  script:
    - gsutil ls -l gs://tests/ |grep staging | sort -k 2 | tail -n 3| head -n 2 |awk '{print $3}' | gsutil -m cp -I .

I get the error:

bash: line 141: gsutil: command not found

Also I checked and gitlab runner is using the same user I used.

The gitlab runner is configured with shell executor.

Changing the command to hold the full path of gsutil didn't help either.

I added whoami to the gitlab-ci.yml and got the result of the same user "runner"

rideler
  • 66
  • 7
  • Even when the runner is configured to use the shell executor, it runs as a different user: `gitlab-runner`. Make sure that, that user has access to `gsutil`. What's the output of `whereis gsutil` and `which gsutil` when you're logged in with your user account? – Tom Jun 01 '21 at 14:18
  • I forgot to mention that this error happens even while using the full path I get from `which gsutil` – rideler Jun 01 '21 at 15:33

1 Answers1

0

I managed to solve this issue by using this solution:

gcloud-command-not-found-while-installing-google-cloud-sdk

I included this 2 line into my gitlab-ci.yml before using the gsutil command.

source '[path-to-my-home]/google-cloud-sdk/path.bash.inc'
source '[path-to-my-home]/google-cloud-sdk/completion.bash.inc'
rideler
  • 66
  • 7