大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
本文由golang教程栏目给大家介绍gol语言项目是怎么配置Gitlab CI的,希望对需要的朋友有所帮助!
创新互联是一家集网站建设,沛县企业网站建设,沛县品牌网站建设,网站定制,沛县网站建设报价,网络营销,网络优化,沛县网站推广为一体的创新建站企业,帮助传统企业提升企业形象加强企业竞争力。可充分满足这一群体相比中小企业更为丰富、高端、多元的互联网需求。同时我们时刻保持专业、时尚、前沿,时刻以成就客户成长自我,坚持不断学习、思考、沉淀、净化自己,让我们为更多的企业打造出实用型网站。pipeline流程使用golangci-lint 检查代码编译代码部署二进制before_script 设置环境变量主要 GOPROXY设置
before_script: - echo "before_script" - git version - go env -w GOPRIVATE=code.haiziwang.com - mkdir -p .go - go version - go env -w GO111MODULE=on - go env -w GOPROXY="https://goproxy.io,direct"golangci-lint
默认集成了很多开箱即用的linter
https://golangci-lint.run/
golangci-lint: image: golangci/golangci-lint:v1.27.0 stage: lint extends: .go-cache allow_failure: true script: - golangci-lint run -v
allow_failure 表示失败了可以继续跑后续的job
编译compile: stage: build extends: .go-cache script: - go mod download - go build -race -o $OUTPUT_NAME artifacts: paths: - $OUTPUT_NAME缓存 go mod
.go-cache: variables: GOPATH: $CI_PROJECT_DIR/.go cache: paths: - .go/pkg/mod/full example
# This file is a template, and might need editing before it works on your project. image: hub-mirror.c.163.com/library/golang:latest .go-cache: variables: GOPATH: $CI_PROJECT_DIR/.go cache: paths: - .go/pkg/mod/ variables: OUTPUT_NAME: helloworld-app stages: - lint - build - deploy before_script: - echo "before_script" - git version - go env -w GOPRIVATE=code.haiziwang.com - mkdir -p .go - go version - go env -w GO111MODULE=on - go env -w GOPROXY="https://goproxy.io,direct" golangci-lint: image: golangci/golangci-lint:v1.27.0 stage: lint extends: .go-cache allow_failure: true script: - golangci-lint run -v compile: stage: build extends: .go-cache script: - go mod download - go build -race -o $OUTPUT_NAME artifacts: paths: - $OUTPUT_NAME deploy-dev: stage: deploy script: - echo "deploy dev environment"