不能在 gitlab 中使用 gsutil cp CI

Can't use gsutil cp with gitlab CI

我在 mac 迷你服务器上使用 gitlab runner。 在使用名为“runner”的用户时,我设法使用了这个命令:

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

我设法获取了文件,但是在 gitlab-ci.yml 中使用相同的命令时是这样的:

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 }' | gsutil -m cp -I .

我收到错误:

bash: line 141: gsutil: command not found

我也检查过,gitlab runner 使用的是我使用的同一个用户。

gitlab runner配置了shell executor.

更改命令以保存 gsutil 的完整路径也没有帮助。

我在gitlab-ci.yml中添加了whoami,得到了同一个用户“runner”的结果

我设法通过使用以下解决方案解决了这个问题:

在使用 gsutil 命令之前,我将这两行包含在我的 gitlab-ci.yml 中。

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