[英]GiLab pipeline failing to push to another repository
I created a new ssh key in my local machine, added the public key to my account settings ssh keys, and the private key to the ci/cd settings of the project.我在本地机器新建了一个 ssh 密钥,将公钥添加到我的账户设置 ssh 密钥中,将私钥添加到项目的 ci/cd 设置中。
My.gitlab-ci.yml looks like the following: My.gitlab-ci.yml 如下所示:
build app:
stage: build
only:
- feature/ci-cd-pipeline-v1
before_script:
- 'command -v ssh-agent >/dev/null || ( apt-get update -y && apt-get install openssh-client -y )'
- eval $(ssh-agent -s)
- echo "$SSH_PRIVATE_KEY" | ssh-add -
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- ssh-keyscan $GIT_URL >> ~/.ssh/known_host
- git config user.email "ci@example.com"
- git config user.name "CI"
- git remote add acquia $GIT_URL
script:
- echo "Script will runb"
- git checkout -b feature/ci-cd-pipeline-v1
- git push acquia feature/ci-cd-pipeline-v1
The goal of this is to push the updated code to my Acquia repository(which also has the ssh public key), but I get the following error when the pipeline runs:这样做的目的是将更新后的代码推送到我的 Acquia 存储库(它也有 ssh 公钥),但是当管道运行时出现以下错误:
$ command -v ssh-agent >/dev/null || ( apt-get update -y && apt-get install openssh-client -y )
$ eval $(ssh-agent -s)
Agent pid 12
$ echo "$SSH_PRIVATE_KEY" | ssh-add -
Error loading key "(stdin)": invalid format
Cleaning up project directory and file based variables
00:01
ERROR: Job failed: exit code 1
I resolved this issue posted by regenerating an RSA key, then secondly, instead of:我通过重新生成 RSA 密钥解决了这个问题,其次,而不是:
tr -d '\n' < ~/.ssh/pipeline_rsa
I use我用
pbcopy < ~/.ssh/pipelines/id_rsa
In summary, the format of the ssh key was incorrect.综上所述,ssh 密钥的格式不正确。
It throws a different error now, but I guess this would form part of a different question.它现在抛出一个不同的错误,但我想这将构成另一个问题的一部分。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.