[英]gitlab ci trying to connect back to git
there is nothing more important to me than ensuring there's no human action involved in the CI process - ie you check into a branch, the ci wakes up, catches up from the main branch, tests, and if everything works fine - it pushes back into the main branch - if anything goes wrong, you just get an email and fix it.对我来说,没有什么比确保 CI 过程中不涉及人为操作更重要的了——即你检查到一个分支,ci 唤醒,从主分支赶上,测试,如果一切正常——它会推回主分支 - 如果出现任何问题,您只需获得 email 并修复它。
I've been trying to implement this with gitlab ci and windows - but I just can't get it working.我一直在尝试用 gitlab ci 和 windows 来实现这个 - 但我就是无法让它工作。 I looked at the merge request stuff, but it really wants a human to create a merge request, which defeats the whole point - also it doesn't do the merge from main -> the feature branch which is important to me.
我查看了合并请求的内容,但它确实需要一个人来创建一个合并请求,这违背了整个观点——它也没有从 main 进行合并——> 对我很重要的特性分支。
So - I've gotten to this point, which seems to work:所以 - 我已经到了这一点,这似乎有效:
host_name=xxxxxxx
project=xxxxxx
key_file_location=xxxx
branch=$CI_COMMIT_REF_NAME
eval $(ssh-agent -s)
ssh-add $key_file_location
git remote set-url origin git@$host_name:$project.git
echo checking out $branch
git checkout $branch
git status
The status even says how I'm going in relationship to the remote branch, so it feels like something worked.状态甚至说明了我将如何与远程分支建立关系,所以感觉像是在起作用。 however - then I then run this command:
但是 - 然后我运行这个命令:
git pull origin main
and it hangs - and when I say hangs - it really just goes away and never comes back - I need to log into the windows box where the gitlab runner is running and issue all of the following to make the runner start working again它挂起 - 当我说挂起时 - 它真的消失了,再也没有回来 - 我需要登录 gitlab 跑步者正在运行的 windows 框,并发出以下所有内容以使跑步者再次开始工作
taskkill /im:git.exe /f
takskill /im:ssh.exe /f
taskkill /im:wish.exe /f
I thought it might be hanging on the "known_hosts" question - so I added the following lines:我认为它可能挂在“known_hosts”问题上 - 所以我添加了以下几行:
ip=`nslookup $host_name 2>&1 | grep Address: | cut -d: -f 2 | sed 's/ //g'`
set +e
ssh-keygen -R $host_name
ssh-keygen -R $host_name
ssh-keygen -R $host_name,$ip
ssh-keyscan -H $host_name,$ip >> ~/.ssh/known_hosts
ssh-keyscan -H $ip >> ~/.ssh/known_hosts
ssh-keyscan -H $host_name >> ~/.ssh/known_hosts
set -e
which achieved exactly nothing.这完全没有取得任何成果。
my runner is running on windows - using the bash shell from git\usr\bin.我的跑步者正在 windows 上运行 - 使用来自 git\usr\bin 的 bash shell。 I am a maintainer of my project, but I'm NOT an administrator on gitlab.
我是我的项目的维护者,但我不是 gitlab 的管理员。
Can anyone tell me either:谁能告诉我:
ok - I got it working by embedding a personal access token as a secret, and pushing back to a http address - but it's a horrible hack:(好的 - 我通过将个人访问令牌作为秘密嵌入并推回 http 地址来使其工作 - 但这是一个可怕的黑客攻击:(
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.