-
Notifications
You must be signed in to change notification settings - Fork 1
/
.drone.yml
168 lines (151 loc) · 3.82 KB
/
.drone.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
---
kind: pipeline
type: kubernetes
name: jparest
platform:
os: linux
arch: amd64
trigger:
event:
include:
- push
- pull_request
steps:
- name: fetch
image: alpine/git
commands:
- "git fetch origin +refs/heads/main:"
- name: test
image: maven:3.8-openjdk-17
depends_on:
- fetch
commands:
- mvn clean install
- name: sonar
image: maven:3.8-openjdk-17
depends_on:
- test
environment:
SONAR_HOST:
from_secret: sonar_cloud_host
SONAR_TOKEN:
from_secret: sonar_cloud_token
commands:
- mvn -X sonar:sonar
-Dsonar.host.url=$${SONAR_HOST}
-Dsonar.login=$${SONAR_TOKEN}
-Dsonar.branch.name=$DRONE_BRANCH
-Dsonar.projectKey=callisto-jparest
-Dsonar.qualitygate.wait=true
when:
event:
exclude:
- pull_request
- name: publish
image: maven:3.8-openjdk-17
depends_on:
- sonar
environment:
GITHUB_TOKEN:
from_secret: github_packages_token
commands:
- mvn -s ./jparest_settings.xml -f pom.xml install -B org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy -DskipTests
- versionExtract=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
- sed -i "/^version=/{s|.$|"=$versionExtract"|}" git_tag.sh
when:
branch: main
event:
exclude:
- pull_request
- name: git tag
image: alpine/git
depends_on:
- publish
environment:
SSH_KEY:
from_secret: github_token
commands:
- chmod 777 git_tag.sh
- ./git_tag.sh
when:
branch: main
event:
exclude:
- pull_request
- name: snapshot
image: maven:3.8-openjdk-17
depends_on:
- sonar
environment:
GITHUB_TOKEN:
from_secret: github_packages_token
commands:
- "BRANCH=$(echo $DRONE_BRANCH | tr '[:lower:]' '[:upper:]') && [[ $BRANCH =~ (EAHW-[0-9]*) ]] && snapshotSuffix=$${match/#E/-E}$${BASH_REMATCH/#E/-E}"
- version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
- mvn versions:set -DnewVersion=$version$${snapshotSuffix}-SNAPSHOT -f pom.xml
- mvn -s ./jparest_settings.xml -f pom.xml install -B deploy -DsnapshotSuffix=$${snapshotSuffix}-SNAPSHOT -DskipTests
when:
branch:
exclude:
- main
---
kind: pipeline
type: kubernetes
name: build notifications
trigger:
status:
- success
- failure
event:
- push
depends_on:
- jparest
steps:
- name: slack
image: plugins/slack
settings:
webhook:
from_secret: SLACK_WEBHOOK_URL
channel: callisto-tech-notifications
username: Drone
template: |
{{#success build.status}}
<${DRONE_BUILD_LINK}|Build #{{ build.number }}> succeeded! :tada:
{{else}}
<${DRONE_BUILD_LINK}|Build #{{ build.number }}> failed :broken_heart:
{{/success}}
Commit: <${DRONE_REPO_LINK}/commit/{{ build.commit }}|{{ truncate build.commit 8 }}> - {{{ trim build.message }}}
Repo: {{ repo.name }}
Branch: <${DRONE_REPO_LINK}/commits/{{ build.branch }}|{{ build.branch }}>
Author: {{ build.author }}
<https://sonarcloud.io/dashboard?id=callisto-jparest&branch={{ build.branch }}&resolved=false|SonarCloud Analysis Report>
---
kind: pipeline
type: kubernetes
name: urgent notifications
trigger:
status:
- failure
event:
- push
depends_on:
- jparest
slack: &slack
image: plugins/slack
settings:
webhook:
from_secret: slack_urgent_webhook_url
channel: callisto-urgent-tech-notifications
username: Drone
steps:
- name: slack_build_urgent
<<: *slack
settings:
template: |
<${DRONE_BUILD_LINK}|Build #{{build.number}}> failed :this-is-fine-fire:
Commit: <${DRONE_REPO_LINK}/commit/{{ build.commit }}|{{ truncate build.commit 8 }}> - {{{ trim build.message }}}
Repo: {{ repo.name }}
Author: {{ build.author }}
when:
branch:
- main