Reputation: 109
Below is the before_script
for my gitlab golang ci project:
before_script:
- git config --global url."[email protected]:".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 [email protected]/<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:
cd src;go get -v -d ./...;
but the ci recognizes the import incorrectly as below and fails:
The issue is that go get somehow is trying to clone the projectname/src.git which doesnt exist.
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
Upvotes: 0
Views: 965
Reputation: 749
try removing this
git config --global url."[email protected]:".insteadOf "https://gitlab.com/"
and all things related to the SSH keys
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.
Upvotes: 3