-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
76 lines (67 loc) · 1.8 KB
/
.gitlab-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
.get-branch-script: &get-branch-script
# CI_COMMIT_BRANCH在PR和tag事件中无效,需要单独处理
- if [ -z $CI_COMMIT_BRANCH ]; then export CI_COMMIT_BRANCH=$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME; fi
# tag事件只能取默认分支:因为tag与分支并无一对一关系
- if [ -z $CI_COMMIT_BRANCH ]; then export CI_COMMIT_BRANCH=$CI_DEFAULT_BRANCH; fi
# gitlab pipelines
default:
interruptible: true
# 指定runner的tag
tags:
- alpha-ci
variables:
GIT_DEPTH: 1
GIT_STRATEGY: fetch
GIT_SUBMODULE_STRATEGY: recursive
PRODUCTION_TAG_REG: '/^v[0-9]+(\.[0-9]+){2,3}$/'
COS_REPO: https://star-deploy-1253924368.cos.ap-beijing.myqcloud.com/unity
stages:
- prepare
- deploy
- publish
workflow:
rules:
# 不处理draft的事件
- if: $CI_COMMIT_MESSAGE =~ /^draft/i
when: never
- if: $CI_COMMIT_TAG
test:prepare:
stage: .pre
image: ccr.ccs.tencentyun.com/solution/docker:20.10.15-alpine3.15
before_script:
- docker system prune --force --volumes || true
- mkdir -p /results/$CI_PIPELINE_ID
- *get-branch-script
- echo "CI_COMMIT_BRANCH=$CI_COMMIT_BRANCH" > .env
- echo $CI_PIPELINE_SOURCE
- echo $PACKAGE_MANAGER_SET
script:
- echo $CI_PIPELINE_ID
artifacts:
reports:
dotenv: .env
test:summary:
stage: .post
variables:
GIT_STRATEGY: none
dependencies:
- test:prepare
image: ccr.ccs.tencentyun.com/solution/python-requests:2.7.18-alpine3.11
before_script:
- echo $CI_COMMIT_BRANCH
script:
- trap 'rm -rf /results/$CI_PIPELINE_ID' EXIT
when: always
.deploy: &deploy
stage: deploy
trigger:
include:
- local: .gitlab/ci/build-deploy.gitlab-ci.yml
strategy: depend
allow_failure: true
deploy:
<<: *deploy
variables:
CI_ENVIRONMENT_NAME: prod
rules:
- if: $CI_COMMIT_TAG