[英]Unable to set up gitlab ci for golang
Below is the before_script
for my gitlab golang ci project:下面是我的 gitlab golang ci 项目的
before_script
:
before_script:
- git config --global url."git@gitlab.com:".insteadOf "https://gitlab.com/"
- apt-get update -qq
- apt-get install -qq git
- 'which ssh-agent || ( apt-get install -qq openssh-client )'
- eval $(ssh-agent -s)
- ssh-add <(echo "$SSH_PRIVATE_KEY")
- mkdir ~/.ssh
- ssh-keyscan -t rsa devsb01 >> ~/.ssh/known_hosts
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
- git remote set-url origin git@gitlab.com/<gitlabusername>/projectName.git
- mkdir -p /go/src/gitlab.com/projectName /go/src/_/builds
- cp -r $CI_PROJECT_DIR /go/src/gitlab.com/projectName
- ls $CI_PROJECT_DIR
- echo $PWD && ls
- make dep
here the Makefile for dep target is as below:这里 dep 目标的 Makefile 如下:
dep:
cd src;go get -v -d ./...;
but the ci recognizes the import incorrectly as below and fails:但 ci 错误地识别导入如下并失败:
The issue is that go get somehow is trying to clone the projectname/src.git which doesnt exist.问题是 go 以某种方式试图克隆不存在的项目名称/src.git。
moving the fileUploader and the test to the src directory solves the issue but moving them to a new controller directory within the src directory fails将 fileUploader 和测试移动到 src 目录可以解决问题,但是将它们移动到 src 目录中的新 controller 目录失败
try removing this尝试删除这个
git config --global url."git@gitlab.com:".insteadOf "https://gitlab.com/"
and all things related to the SSH keys以及与 SSH 键相关的所有内容
and add this line并添加这一行
echo -e "machine gitlab.com\nlogin gitlab-ci-token\npassword ${CI_JOB_TOKEN}" > ~/.netrc
the .netrc
will allow you the access to the private repo, for gitlab CI you do not need to handle ssh keys. .netrc
将允许您访问私有存储库,对于 gitlab CI,您不需要处理 ssh 密钥。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.