forked from TheHive-Project/TheHive
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.drone.yml
205 lines (181 loc) · 5.56 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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
---
kind: pipeline
name: default
# Disable default clone
clone:
disable: true
steps:
# This clone step doesn't use "root" user
- name: clone
image: plugins/git:next
# 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
- sbt -Duser.home=$PWD test stage
# Build packages
- name: build-packages
image: thehiveproject/drone-scala-node
settings:
pgp_key: {from_secret: pgp_key}
commands:
- |
. ~/.nvm/nvm.sh
[ -n "$PLUGIN_PGP_KEY" ] && gpg --batch --import - <<< $PLUGIN_PGP_KEY
sbt -Duser.home=$PWD docker:stage debian:packageBin rpm:packageBin universal:packageBin
when:
event: [tag]
# Save external libraries in cache
- name: save-cache
image: drillster/drone-volume-cache
settings:
rebuild: true
mount:
- .sbt
- .ivy2
- ui/node_modules
- ui/bower_components
volumes: [{name: cache, path: /cache}]
- name: publish-package
image: thehiveproject/drone-bintray
settings:
user: {from_secret: bintray_user}
key: {from_secret: bintray_key}
subject: thehive-project
package: thehive
commands:
- |
export PLUGIN_USER
export PLUGIN_KEY
export PLUGIN_SUBJECT
export PLUGIN_PACKAGE
export PLUGIN_VERSION=$(cut -d\" -f2 version.sbt)
echo "Publishing package version $PLUGIN_VERSION"
if echo $PLUGIN_VERSION | grep -qvi -E \
-e '^[0-9]+\.[0-9]+\.[0-9]+$' \
-e '^[0-9]+\.[0-9]+\.[0-9]+-[0-9]+$' \
-e '^[0-9]+\.[0-9]+\.[0-9]+-RC[0-9]+$'; then
echo The version $PLUGIN_VERSION has invalid format
exit 1
fi
CHANNEL=stable
if $(echo $PLUGIN_VERSION | grep -qi rc)
then
CHANNEL=beta
V=$(echo $PLUGIN_VERSION | sed -e 's/-\([rR][cC]\)/-0.1\1/')
DEB_FILE=target/thehive_$${V}_all.deb
RPM_FILE=target/rpm/RPMS/noarch/thehive-$${V}.noarch.rpm
else
DEB_FILE=target/thehive_$${PLUGIN_VERSION}_all.deb
RPM_FILE=target/rpm/RPMS/noarch/thehive-$${PLUGIN_VERSION}.noarch.rpm
fi
ZIP_FILE=target/universal/thehive-$${PLUGIN_VERSION}.zip
upload \
--file $DEB_FILE \
--repo debian-beta \
--extra-param deb_distribution=any \
--extra-param deb_component=main \
--extra-param deb_architecture=all
[ $CHANNEL = stable ] && upload \
--file $DEB_FILE \
--repo debian-stable \
--extra-param deb_distribution=any \
--extra-param deb_component=main \
--extra-param deb_architecture=all
upload \
--file $RPM_FILE \
--repo rpm-beta
[ $CHANNEL = stable ] && upload \
--file $RPM_FILE \
--repo rpm-stable
upload \
--file $ZIP_FILE \
--repo binary
LATEST_VERSION=latest
[ $CHANNEL = beta ] && LATEST_VERSION=latest-beta
removeVersion \
--repo binary \
--version $LATEST_VERSION
upload \
--file $ZIP_FILE \
--repo binary \
--version $LATEST_VERSION \
--dest-file thehive-$${LATEST_VERSION}.zip
when:
event: [tag]
# Publish docker image
- name: docker
image: plugins/docker
settings:
context: target/docker/stage
dockerfile: target/docker/stage/Dockerfile
repo: thehiveproject/thehive
auto_tag: true
username: {from_secret: docker_username}
password: {from_secret: docker_password}
when:
event: [tag]
# Deploy binaries in integration environment
- name: copy binaries in integration environment
image: appleboy/drone-scp
settings:
host: {from_secret: deploy_beta_host}
username: {from_secret: deploy_username}
key: {from_secret: deploy_key}
target: ./thehive-builds/${DRONE_BUILD_NUMBER}
source: target/universal/stage
strip_components: 3
when:
branch: [develop]
event: {exclude: [pull_request]}
- name: deploy binaries in integration environment
image: appleboy/drone-ssh
settings:
host: {from_secret: deploy_beta_host}
username: {from_secret: deploy_username}
key: {from_secret: deploy_key}
script:
- ./start thehive ${DRONE_BUILD_NUMBER}
when:
branch: [develop]
event: {exclude: [pull_request]}
# Deploy binaries in staging environment
- name: copy binaries in staging environment
image: appleboy/drone-scp
settings:
host: {from_secret: deploy_stable_host}
username: {from_secret: deploy_username}
key: {from_secret: deploy_key}
target: ./thehive-builds/${DRONE_BUILD_NUMBER}
source: target/universal/stage
strip_components: 3
when:
branch: [master]
event: {exclude: [pull_request]}
- name: deploy binaries in staging environment
image: appleboy/drone-ssh
settings:
host: {from_secret: deploy_stable_host}
username: {from_secret: deploy_username}
key: {from_secret: deploy_key}
script:
- ./start thehive ${DRONE_BUILD_NUMBER}
when:
branch: [master]
event: {exclude: [pull_request]}
volumes:
- name: cache
host:
path: /opt/drone/cache