Can't use another project repository as a golang package
Hi there!
I have two repos in the same space project: service
and shared-libs
and if I try to use shared-libs
as a module in service
, I will get error.
go: git.jetbrains.space/**/**/service/cmd/srv imports
git.jetbrains.space/**/**/shared-libs/clock: reading git.jetbrains.space/**/**/shared-libs/go.mod at revision v1.0.0: git ls-remote -q origin in /go/pkg/mod/cache/vcs/d11e012419cedecaa3d23d8838eefd7cedf027a5d808714b273ffd5462c2f517: exit status 128:
Host key verification failed.
fatal: Could not read from remote repository.
My .space.kts
looks like:
job("Checking source") {
startOn {
codeReviewOpened{
branchToCheckout = CodeReviewBranch.MERGE_REQUEST_SOURCE
}
}
parallel {
container(displayName = "Linting", image = "golangci/golangci-lint:latest") {
shellScript {
content = "golangci-lint --exclude-use-default=false run ./..."
}
}
container(displayName = "Unit testing", image = "golang:latest") {
shellScript {
content = """
# Get dependencies
go mod vendor
# Run tests
go test -coverprofile coverage.out -race $(go list ./... | grep -v /vendor/)
# Display coverage
go tool cover -func=coverage.out
"""
}
}
}
}
Please sign in to leave a comment.
Me Hi,
Unfortunately, the issue here is with the SSH command used while getting the source code from the initial repo. To avoid the “Host key verification failed” error, you can add “-o StrictHostKeyChecking=no” and point to the right path ("${'$'}JB_SPACE_STEP_DATA_PATH/system/id_rsa") where the SSH key for the Automation job is. This needs to be done before calling the Go modules. Here is the snippet with an example: