加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
.gitlab-ci.yml~gitlab_feature_fix-cert 3.07 KB
一键复制 编辑 原始数据 按行查看 历史
stages:
- notice
- check
- build
- deploy
- publish
variables:
PATH: /usr/local/sonar-scanner/sonar-scanner-4.4.0.2170-linux/bin:/usr/local/bin:/usr/local/sbin:/usr/sbin:/usr/bin:/data/golang/go/bin/:/root/go/bin
GOROOT: /data/golang/go
GOPROXY: https://goproxy.cn
APP: apinto
VERSION: $CI_COMMIT_SHORT_SHA
SAVE_DIR: /opt/apinto
APP_PRE: ${APP}-${VERSION}
default:
before_script:
- pwd
merge-informer: # 飞书回调
stage: notice
variables:
DIFF_URL: "$CI_MERGE_REQUEST_PROJECT_URL/-/merge_requests/$CI_MERGE_REQUEST_IID/diffs"
rules:
- if: $CI_PIPELINE_SOURCE=="merge_request_event"
script:
- rm -rf out/apinto-*
- |
curl -X POST -H "Content-Type: application/json" \
-d "{\"msg_type\":\"text\",\"content\":{\"text\":\"项目:${CI_PROJECT_NAME}\\n提交人:${GITLAB_USER_NAME}\\n提交信息:${CI_MERGE_REQUEST_TITLE}\\n合并分支信息:${CI_MERGE_REQUEST_SOURCE_BRANCH_NAME} -> ${CI_MERGE_REQUEST_TARGET_BRANCH_NAME}\\n差异性地址:${DIFF_URL}\\n请及时review代码\"}}" \
https://open.feishu.cn/open-apis/bot/v2/hook/1c334752-2874-41a1-8f1b-3060f2d46b6c
checker:
stage: check
rules:
- if: $CI_COMMIT_BRANCH=="develop"
script:
- set +e
- go mod tidy
- go test -covermode=atomic -coverpkg=./... -coverprofile=coverage.data -timeout=1m ./...
- golangci-lint run --timeout=3m --out-format checkstyle --issues-exit-code 0 ./... > report.xml
- sonar-scanner
builder:
stage: build
rules:
- if: $CI_COMMIT_BRANCH=="develop"
when: on_success
- if: $CI_COMMIT_BRANCH=="test"
when: on_success
script:
- sed -i '/replace github.com\/eolinker\/eosc => */d' go.mod
- go mod tidy
- cd build/cmd && ./package.sh $VERSION
cache:
paths:
- out/
deployer:
stage: deploy
rules:
- if: $CI_COMMIT_BRANCH=="develop"
variables:
DEPLOY_SERVER: root@172.18.189.43
DEPLOY_DESC: "DEV 环境"
- if: $CI_COMMIT_BRANCH=="test"
variables:
DEPLOY_SERVER: root@172.18.65.60
DEPLOY_DESC: "TEST 环境"
dependencies:
- builder
script:
- set -e
- scp out/${APP_PRE}.linux.x64.tar.gz ${DEPLOY_SERVER}:${SAVE_DIR}
- ssh ${DEPLOY_SERVER} "set -e; cd ${SAVE_DIR}; mkdir -p ${APP_PRE};tar -zxvf ${APP_PRE}.linux.x64.tar.gz -C ${APP_PRE};cd ${APP_PRE}/${APP}; ./install.sh upgrade;cd ${SAVE_DIR}; ./clean.sh ${APP_PRE}"
- |
curl -X POST -H "Content-Type: application/json" \
-d "{\"msg_type\":\"text\",\"content\":{\"text\":\"项目:apinto\\n环境:${DEPLOY_DESC}\\n更新部署完成.\"}}" \
https://open.feishu.cn/open-apis/bot/v2/hook/1c334752-2874-41a1-8f1b-3060f2d46b6c
when: on_success
cache:
paths:
- out/
publisher:
stage: publish
only:
- tags
script:
- sed -i '/replace github.com\/eolinker\/eosc => */d' go.mod
- go mod tidy
- GOVERSION=$(go version) EoscVersion=$(sed -n 's/.*eosc v/v/p' go.mod) goreleaser release --skip-validate --rm-dist --skip-publish
- mkdir -p /data/pkg/apinto/${CI_COMMIT_TAG}
- cp -if dist/*.tar.gz /data/pkg/apinto/${CI_COMMIT_TAG}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化