简体   繁体   English

如何获得GitLab CI / CD作业以推送到外部存储库?

[英]How can I get GitLab CI/CD jobs to push to external repositories?

I've been having issues getting Gitlab CI/CD to push new changes to the current repository. 我在让Gitlab CI / CD将新的更改推送到当前存储库时遇到了问题。 Apparently, this can not be done as of now. 显然,到目前为止还无法完成。 So now, I am attempting to see if it can push to other repositories. 所以现在,我正在尝试查看它是否可以推送到其他存储库。

This is what I'm trying to do: 这就是我想要做的:

  • Clone another repo into mine 将另一个仓库克隆到我的仓库中
    • let's call mine Router ) 我们称我的路由器为
    • let's call the other Rinner ) 让我们打电话给另一个Rinner
  • Modify Rinner in some way 以某种方式修改Rinner
  • Commit and Push only the changes to Rinner 提交并仅将更改推送到Rinner
  • Then remove Rinner from Router 然后从路由器中删除Rinner

I'm trying to test this out in Python, and currently have this: 我正在尝试在Python中进行测试,目前有:

    os.system('mkdir temp');
    os.chdir('temp');
    os.system('git clone git@gitlab.com/path/Rinner.git');
    os.chdir('Rinner');
    os.system('echo "Hello World!" > hello.txt');
    os.system('git add -A');
    os.system('git commit -m "Running a test..."');
    os.system('git push --force');
    os.chdir('..');
    os.chdir('..');
    os.system('rm -rf temp');

On my local machine, it works perfect fine. 在我的本地计算机上,它可以完美运行。

On my GitLab CI/CD job, I get the following result. 在我的GitLab CI / CD工作中,得到以下结果。

Cloning into 'Rinner'...
Host key verification failed.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

How can I go about getting past this when it operates on GitLab CI/CD? 当它在GitLab CI / CD上运行时,如何解决这个问题?

You are cloning git clone git@gitlab.com/path/Rinner.git over SSH and problem is that You have wrong fingerprint of server stored on your runner in ~/.ssh/known_hosts 您正在通过SSH克隆git clone git@gitlab.com/path/Rinner.git ,问题是您在〜/ .ssh / known_hosts中的运行程序上存储了错误的服务器指纹

You can try also ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null git@gitlab.com vs ssh git@gitlab.com . 您也可以尝试ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null git@gitlab.comssh git@gitlab.com You will se a difference. 您会有所不同。

You need to remove this fingerprint or disable StrictHostKeyChecking 您需要删除此指纹或禁用StrictHostKeyChecking

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM