在Debian上搭建Golang CI/CD,可參考以下步驟:
sudo apt install golang-go
安裝Go,安裝后可通過go version
驗證。~/.bashrc
或~/.profile
,添加export PATH=$PATH:/usr/local/go/bin
,并使配置生效。.gitlab-ci.yml
文件,定義CI流程,如包含構建、測試階段。示例配置如下:stages:
- build
- test
build:
stage: build
image: golang:latest
script:
- go build -o myapp .
test:
stage: test
image: golang:latest
script:
- go test ./...
- 確保有GitLab Runner在運行并注冊到GitLab實例。
.gitlab-ci.yml
文件自動觸發構建和測試流程。