ubuntu 20.04 可以作为 girlab-runner 主机吗

Running with gitlab-runner 14.10.0 (c6bb62f6)
  on ceshi 1zacech2
Preparing the "shell" executor
00:00
Using Shell executor...
Preparing environment
00:01
+ set -o
+ grep pipefail
+ set -o errexit
+ set +o noclobber
+ :
+ eval $echo "Running on $(hostname)..."\n
+ hostname
+ Running on k8s-node...n
sh: 1: eval: Running on k8s-node...n: not found
ERROR: Job failed: prepare environment: exit status 127. Check https://docs.gitlab.com/runner/shells/index.html#shell-profile-loading for more information

根据官方issue 提供的解决办法,我检查了家目录(/home/gitlab-runner/),但是里面是空的,并没有.bash_logout文件。

首先,Ubuntu20.04是可以安装gitlab-runner的:

仓库方式: Install GitLab Runner using the official GitLab repositories | GitLab
二进制方式:Install GitLab Runner manually on GNU/Linux | GitLab

其次,从报错信息"sh: 1: eval: Running on k8s-node…n: not found"来看,是命令写法有问题,建议把.gitlab-ci.yml发上来看一下。

stages:
  - sonarqube-check

variables:
  SONAR_HOST_URL: http://192.168.10.42:9000
  SONAR_TOKEN: XXX

sonarqube-check:
  tags:
    - ceshi
  stage: sonarqube-check
  image: mcr.microsoft.com/dotnet/core/sdk:latest
  variables:
    SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar"
    GIT_DEPTH: "0"
    PROJECT_NAME: "XXX"
    CI_DEBUG_TRACE: "true"
  script: 
    #- "sudo apt-get update"
    #- "sudo apt-get install --yes openjdk-11-jre"
    - "export PATH=\"$PATH:$HOME/.dotnet/tools\""
    - "export PATH=\"$PATH:/home/gitlab-runner/.dotnet/tools\""
    #- "dotnet tool install --global dotnet-sonarscanner"
    - "whoami"
    - "cd ./src"
    - "ls -lh"
    #- "ls -lh /home/gitlab-runner/.dotnet/tools"
    - "dotnet sonarscanner begin /k:$PROJECT_NAME /d:sonar.qualitygate.wait=true /d:sonar.qualitygate.timeout=300 /d:sonar.login=\"$SONAR_TOKEN\" /d:\"sonar.host.url=$SONAR_HOST_URL\" /d:\"sonar.verbose=true\" "
    - "dotnet build"
    - "dotnet sonarscanner end /d:sonar.login=\"$SONAR_TOKEN\""
  allow_failure: false
  only:
    - main

@Alex

如果需要script中的命令在image中运行,需要首先注册一个docker类型的执行器,参照example:How to configure GitLab Runner for GitLab CE integration tests | GitLab

docker 执行器 如何指定用户呢?

docker执行器一般是不要指定用户的,镜像中默认的用户一般都是能直接执行script中相应命令的。
建议结合你的另外一个帖子,创建一个docker执行器。