In Gitlab CI, I need to specify GITLAB_DEPLOY_TOKEN
, as I have some private repositories. This works well for compile step.
But when I execute golint, it will download again all dependencies, and it will fail on private ones. I could add the same git config
directive,
image: golang variables: PACKAGE_PATH: /go/src/gitlab.com/company/sam/daemon PACKAGE_API_NAME: registry.gitlab.com/company/sam/daemon REGISTRY_URL: https://registry.gitlab.com DOCKER_DRIVER: overlay GO111MODULE: "on"
.anchors: - &inject-gopath mkdir -p $(dirname ${PACKAGE_PATH}) && ln -s ${CI_PROJECT_DIR} ${PACKAGE_PATH} && cd ${PACKAGE_PATH}
compile:
stage: build
before_script:
- *inject-gopath
- git config --global url."https://oauth:${GITLAB_DEPLOY_TOKEN}@gitlab.com".insteadOf https://gitlab.com
- go mod tidy
script: GOOS=linux GOARCH=arm GOARM=7 go build -o release/daemon .
artifacts:
name: "binary-$CI_PIPELINE_ID"
paths:
- $GOPATH/pkg/mod/
expire_in: 1 hour
lint:
stage: test
before_script:
- apt install -y curl git
- go get github.com/golang/lint
- *inject-gopath
script:
- $GOPATH/bin/golint -set_exit_status $(go list ./...)
allow_failure: true
I read here that go modules were cached in $GOPATH/pkg/mod
but it doesn't seem to work
Any idea how should I fix it ?