forked from TheHive-Project/Cortex
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.drone.yml
182 lines (169 loc) · 5.21 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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
---
kind: pipeline
name: default
type: docker
steps:
# Restore cache of downloaded dependencies
- name: restore-cache
image: drillster/drone-volume-cache
settings:
restore: true
mount:
- .sbt
- .ivy2
- ui/node_modules
- ui/bower_components
volumes: [{name: cache, path: /cache}]
# Run project tests
- name: run-tests
image: thehiveproject/drone-scala-node
commands:
- |
. ~/.nvm/nvm.sh
nvm install 12.18
npm install -g bower
sbt -Duser.home=$PWD test:compile test Universal/packageBin
# Build packages
- name: build-packages
image: thehiveproject/drone-scala-node
settings:
pgp_key: {from_secret: pgp_key}
commands:
- |
V=$(sbt -no-colors --error "print cortex/version" | tail -1)
if ( echo $V | grep -qi snapshot)
then
exit 1
fi
. ~/.nvm/nvm.sh
nvm install 12.18
npm install -g bower
[ -n "$PLUGIN_PGP_KEY" ] && gpg --batch --import - <<< $PLUGIN_PGP_KEY
sbt -Duser.home=$PWD Docker/stage Debian/packageBin Rpm/packageBin Universal/packageBin cortexWithDeps/Docker/stage
if ( echo $V | grep -qi rc )
then
echo $( echo $V | sed -re 's/([0-9]+.[0-9]+.[0-9]+)-RC([0-9]+)-([0-9]+)/\1-RC\2,\1-RC\2-\3/' ) > .tags
else
echo $( echo $V | sed -re 's/([0-9]+).([0-9]+).([0-9]+)-([0-9]+)/\1,\1.\2,\1.\2.\3,\1.\2.\3-\4,latest/' ) > .tags
fi
echo $V > cortex-version.txt
mv target/rpm/RPMS/noarch/cortex*.rpm target/
mv target/universal/cortex*.zip target/
when:
event: [tag]
# Save external libraries in cache
- name: save-cache
image: drillster/drone-volume-cache
settings:
rebuild: true
backend: "filesystem"
mount:
- .sbt
- .ivy2
- .cache
- ui/node_modules
- ui/bower_components
volumes: [{name: cache, path: /cache}]
# Send packages using scp
- name: send packages
image: appleboy/drone-scp
settings:
host: {from_secret: package_host}
username: {from_secret: package_user}
key: {from_secret: package_key}
target: {from_secret: incoming_path}
source:
- target/cortex*.deb
- target/cortex*.rpm
- target/cortex*.zip
strip_components: 1
when:
event: [tag]
# Publish packages
- name: publish packages
image: appleboy/drone-ssh
settings:
host: {from_secret: package_host}
user: {from_secret: package_user}
key: {from_secret: package_key}
publish_script: {from_secret: publish_script}
commands:
- PLUGIN_SCRIPT="bash $PLUGIN_PUBLISH_SCRIPT cortex $(cat cortex-version.txt)" /bin/drone-ssh
when:
event: [tag]
# Publish docker image on Docker Hub
- name: docker
image: plugins/docker
settings:
context: target/docker/stage
dockerfile: target/docker/stage/Dockerfile
repo: thehiveproject/cortex
username: {from_secret: docker_username}
password: {from_secret: docker_password}
when:
event: [tag]
# Publish docker image on Harbor
- name: harbor
image: plugins/docker
settings:
context: target/docker/stage
dockerfile: target/docker/stage/Dockerfile
registry: {from_secret: harbor_registry}
repo: {from_secret: harbor_repo}
username: {from_secret: harbor_username}
password: {from_secret: harbor_password}
when:
event: [tag]
- name: update docker tags
image: thehiveproject/drone-scala-node
commands:
- sed -i -e 's/,/-withdeps,/g; s/$/-withdeps/' .tags
when:
event: [tag]
# Publish docker image on Docker Hub
- name: docker fat
image: plugins/docker
settings:
context: target/docker-withdeps/target/docker/stage
dockerfile: target/docker-withdeps/target/docker/stage/Dockerfile
repo: thehiveproject/cortex
username: {from_secret: docker_username}
password: {from_secret: docker_password}
when:
event: [tag]
# Publish docker image on Harbor
- name: harbor fat
image: plugins/docker
settings:
context: target/docker-withdeps/target/docker/stage
dockerfile: target/docker-withdeps/target/docker/stage/Dockerfile
registry: {from_secret: harbor_registry}
repo: {from_secret: harbor_repo}
username: {from_secret: harbor_username}
password: {from_secret: harbor_password}
when:
event: [tag]
- name: send message
image: thehiveproject/drone_keybase
settings:
username: {from_secret: keybase_username}
paperkey: {from_secret: keybase_paperkey}
channel: {from_secret: keybase_channel}
commands:
- |
keybase oneshot -u "$PLUGIN_USERNAME" --paperkey "$PLUGIN_PAPERKEY"
URL="$DRONE_SYSTEM_PROTO://$DRONE_SYSTEM_HOST/$DRONE_REPO/$DRONE_BUILD_NUMBER"
if [ $DRONE_BUILD_STATUS = "success" ]
then
keybase chat send "$PLUGIN_CHANNEL" ":white_check_mark: $DRONE_REPO: build succeeded $URL"
else
keybase chat send "$PLUGIN_CHANNEL" ":x: $DRONE_REPO: build failed $URL"
fi
when:
status:
- success
- failure
volumes:
- name: cache
host:
path: /opt/drone/cache