【问题标题】:Gitlab pipeline error With CD/CI for AWS ec2 debian instance: This job is stuck because you don't have any active runners onlineGitlab 管道错误与 AWS ec2 debian 实例的 CD/CI:此作业被卡住,因为您没有任何在线的活动跑步者
【发布时间】:2022-01-21 09:21:40
【问题描述】:

我想在 gitlab 和 aws ec2 部署之间创建一个 CI/CD 管道。 我的存储库是 nodejs/express 网络服务器项目。

我创建了一个 gitlab-ci.yaml

image: node:latest

cache:
  paths:
    - node_modules/

stages:
  - build
  - test
  - staging
  - openMr
  - production


before_script:  
  - apt-get update -qq && apt-get install

Build:
  stage: build
  tags:
    - node
  before_script: 
    - yarn config set cache-folder .yarn
    - yarn install 
  script:
    - npm run build

Test:
  stage: test
  tags:
  - node
  before_script: 
    - yarn config set cache-folder .yarn
    - yarn install --frozen-lockfile
  script:
    - npm run test


Deploy to Production:
  stage: production
  tags:
    - node
  before_script:
    - mkdir -p ~/.ssh
    - echo -e "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
    - chmod 600  ~/.ssh/id_rsa
    - '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'   
  script:     
    - bash ./gitlab-deploy/.gitlab-deploy.prod.sh   
  environment:     
    name: production     
    url: http://ec2-url.compute.amazonaws.com:81   

当我推送新的提交管道时,构建步骤失败。我收到警告:

这项工作被卡住了,因为您没有任何活跃的在线跑步者或 可与分配给它们的任何这些标签一起使用:节点

我在 gitlab settings/CI/CD 上检查了我的跑步者

之后我检查了服务器

admin@ip-111.222.222.111:~$ gitlab-runner
 statusRuntime platform                                    arch=amd64 os=linux pid=18787 revision=98daeee0 version=14.7.0
FATAL: The --user is not supported for non-root users 

【问题讨论】:

  • 该错误表明运行器无法启动,因为您已为运行器配置了运行用户,但您只能使用 root 权限执行此操作。你可以试试sudo gitlab-runner

标签: amazon-ec2 gitlab continuous-integration debian cicd


【解决方案1】:

您需要从您的工作中删除标签node。跑步者标签用于定义哪个跑步者应该接你的工作(https://docs.gitlab.com/ee/ci/runners/configure_runners.html#use-tags-to-control-which-jobs-a-runner-can-run)。由于没有支持标签node的跑步者,你的工作会卡住。

您的管道看起来没有任何特殊要求,因此您只需删除标签,以便每个跑步者都可以拿起它。

您的屏幕截图中可以看到的跑步者支持标签shop_service_runner。因此,另一种选择是将标签 node 更改为 shop_service_runner,这将导致该跑步者(以及具有相同标签的每个跑步者)能够接受这份工作。

【讨论】:

    猜你喜欢
    • 2020-05-23
    • 2019-04-21
    • 1970-01-01
    • 2021-08-19
    • 2020-10-30
    • 2021-04-17
    • 2021-11-30
    • 2014-05-25
    • 2021-03-28
    相关资源
    最近更新 更多