I’m trying to setup a ci job to check that the go mod tidy command has been run on the the golang repo. For go modules it needs to fetch a dependent repo, and uses git fetch -f origin, but fails with the error “Host key verification failed. fatal: Could not read from remote repository.” I’ve already tried setting GOPRIVATE and GOFLAGS=-mod=vendor, and even git config --global "url.git@my-domain.org:".insteadof "https://my-domain.org", but can’t seem to make it work. Any ideas?
mod:tidy:
stage: test
image: golang:1.13
script:
- export GOPRIVATE=my-domain.org
- export GOFLAGS=-mod=vendor
- git config --global "url.git@my-domain.org:".insteadof "https://my-domain.org"
- go mod tidy
REPO_NAME=“my-domain.org/$CI_PROJECT_PATH”
$ mkdir -p $GOPATH/src/$(dirname $REPO_NAME)
$ ln -svf $CI_PROJECT_DIR $GOPATH/src/$REPO_NAME
‘/go/src/my-domain.org/my/project’ → ‘/builds/my/project’
$ cd $GOPATH/src/$REPO_NAME
$ export GOPRIVATE=my-domain.org
$ export GOFLAGS=-mod=vendor
$ git config --global “url.git@my-domain.org:”.insteadof “https://my-domain.org”
$ go mod verify
go: my-domain.org/my/dependency@v0.0.0-20191003182426-5c18e64a884b: invalid version: git fetch -f origin refs/heads/:refs/heads/ refs/tags/:refs/tags/ in /go/pkg/mod/cache/vcs/65bd88526e3cdbc3eee62ac6cd8ba1be7cd11392c0870d0b0271ea4cbc172f58: exit status 128:
Host key verification failed.
fatal: Could not read from remote repository.Please make sure you have the correct access rights
and the repository exists.
ERROR: Job failed: exit code 1