【发布时间】: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