Before we start
I have created a new project under $GOPATH and copy the all the files from the glide-example. That includes:
- README.md (optional)
Make sure they could be built and run locally.
Setup the pipeline
Let’s start with adding the following pipeline file to the project root folder.
Commit and push this new .gitlab-ci.yaml file to gitlab. Then check the pipeline job.
The error indicates that the build could not locate the vendor package. This is because the checkout project path of the GitLab CI job is /builds/ykyuen/gitlab-ci-go-build which is not under $GOPATH.
In order to fix the build error, we have to make sure the project is under $GOPATH. This could be done by creating a symbolic link before starting the build process. Let’s update the .gitlab-ci.yaml.
Commit and push the change and try the pipeline job again.
- Go project should be always under $GOPATH.
- Checkin the vendor folder could simplify the pipeline as we do not need to run the glide install command.