【发布时间】:2023-03-10 15:30:01
【问题描述】:
这是我的代码 giltlab-ci.yml :
before_script:
##
## Install ssh-agent if not already installed, it is required by Docker.
## (change apt-get to yum if you use an RPM-based image)
##
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
##
## Run ssh-agent (inside the build environment)
##
- eval $(ssh-agent -s)
##
## Add the SSH key stored in SSH_PRIVATE_KEY variable to the agent store
## We're using tr to fix line endings which makes ed25519 keys work
## without extra base64 encoding.
## https://gitlab.com/gitlab-examples/ssh-private-key/issues/1#note_48526556
##
- mkdir -p ~/.ssh
#- echo -n "$PROJECT_SSH_KEY" | ssh-add - >/dev/null
- echo "$PROJECT_SSH_KEY"
- ssh-add <(echo "$PROJECT_SSH_KEY")
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
##
## Create the SSH directory and give it the right permissions
##
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
##
## Optionally, if you will be using any Git commands, set the user name and
## and email.
##
#- git config --global user.email "user@example.com"
#- git config --global user.name "User name"
我把这个拿出来
使用 gitlab-runner 11.8.0 (4745a6f3) 运行 在 Allence-Tunisie-docker-runner sH47eTgb 使用带有镜像 ntfactory/ci-tool:0.0.2 的 Docker 执行器 ... 正在拉取 docker 镜像 ntfactory/ci-tool:0.0.2 ... 使用泊坞窗图像 sha256:7fe7b170806f6846271eec23b41c4f79202777f62c0d7a32165dc41722900979 对于 ntfactory/ci-tool:0.0.2 ... 通过 a732493b4b94 在 runner-sH47eTgb-project-11060727-concurrent-0 上运行... 克隆存储库... 克隆到“/builds/allence-tunisie/e-formation”... 将 0a6b48ef 签出为 feat/gitlab-ci... 跳过 Git 子模块设置 正在检查默认缓存... 未提供 URL,不会从共享缓存服务器下载缓存。相反,将提取本地版本的缓存。 成功提取缓存 $ 哪个 ssh 代理 || ( apt-get update -y && apt-get install openssh-client -y ) /usr/bin/ssh-agent $ eval $(ssh-agent -s) 代理 pid 12 $ mkdir -p ~/.ssh $ echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null 加载键“(stdin)”时出错:格式无效 错误:作业失败:退出代码 1
即使我尝试过 - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-添加 - > /dev/null 我得到这个错误
加载键“(stdin)”时出错:格式无效
【问题讨论】:
-
你能解决这个错误吗?
-
是的,实际上问题出在 ssh 密钥上
标签: gitlab-ci