-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.drone.yml
183 lines (165 loc) · 4.43 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
type: docker
name: default
environment:
DATABASE_HOST: postgres-1
DATABASE_NAME: opertusmundi
DATABASE_USER: opertusmundi
BPM_REST_USERNAME: admin
#
# Steps
#
steps:
- name: setup-database
image: postgres:10.14-alpine
when:
event:
- push
environment:
DATABASE_POSTGRES_PASSWORD:
from_secret: database_postgres_password
DATABASE_PASSWORD:
from_secret: database_password
commands:
- export PGHOST=$${DATABASE_HOST}
- (t=30; while ! pg_isready -U postgres -t 5; do t=$((t - 1)); test $${t} -ne 0; sleep 3s; done)
# Setup client
- touch ~/.pgpass
- chmod og-rwx ~/.pgpass
- echo "$${DATABASE_HOST}:5432:*:postgres:$${DATABASE_POSTGRES_PASSWORD}" >> ~/.pgpass
- echo "$${DATABASE_HOST}:5432:*:$${DATABASE_USER}:$${DATABASE_PASSWORD}" >> ~/.pgpass
# Create user/database for tests
- echo "CREATE USER \"$${DATABASE_USER}\" WITH PASSWORD '$${DATABASE_PASSWORD}'" | psql -U postgres
- echo "CREATE DATABASE \"$${DATABASE_NAME}\" WITH OWNER \"$${DATABASE_USER}\"" | psql -U postgres
- psql -U postgres -l -A -t
- psql -U $${DATABASE_USER} -d $${DATABASE_NAME} -A -t -c '\d'
- name: checkout-submodules
image: alpine/git:v2.30.1
when:
event:
- push
- tag
commands:
- git submodule init
- git submodule update --recursive
- name: resolve-deps
#image: maven:3.8.6-eclipse-temurin-17-alpine
image: opertusmundi/java-commons-builder:1.1
when:
event:
- push
environment: {}
volumes:
- name: maven-repo
path: /root/.m2
commands:
- mvn -B -pl common install
- mvn -B dependency:resolve
- name: generate-configuration-for-testing
image: busybox:1.32
when:
event:
- push
environment:
DATABASE_PASSWORD:
from_secret: database_password
JWT_SECRET:
from_secret: jwt_secret
BPM_REST_PASSWORD:
from_secret: bpm_rest_password
commands:
# Generate configuration for testing
- mkdir -p ./bpm-worker/config
- config_file=./bpm-worker/config/application-testing.properties
- >-
( echo "spring.datasource.url=jdbc:postgresql://$${DATABASE_HOST}:5432/$${DATABASE_NAME}";
echo "spring.datasource.username=$${DATABASE_USER}";
echo "spring.datasource.password=$${DATABASE_PASSWORD}";
echo
echo "opertus-mundi.bpm.worker.rest.base-url = http://bpm-server:8000/engine-rest";
echo "opertus-mundi.bpm.worker.rest.username = $${BPM_REST_USERNAME}";
echo "opertus-mundi.bpm.worker.rest.password = $${BPM_REST_PASSWORD}";
echo
echo "opertusmundi.feign.jwt.secret = $${JWT_SECRET}";
) | tee $${config_file}
- name: tests
#image: maven:3.8.6-eclipse-temurin-17-alpine
image: opertusmundi/java-commons-builder:1.1
when:
event:
- push
volumes:
- name: maven-repo
path: /root/.m2
environment: {}
commands:
- mvn test -B -DenableCiProfile
- name: integration-tests
#image: maven:3.8.6-eclipse-temurin-17-alpine
image: opertusmundi/java-commons-builder:1.1
when:
event:
- push
volumes:
- name: maven-repo
path: /root/.m2
environment: {}
commands:
- mvn verify -B -DenableCiProfile
- name: prepare-tags
image: busybox:1.32
when:
event:
- tag
commands:
- tags_file=$(mktemp)
- echo ${DRONE_TAG} | grep -e '^[0-9]\+[.][0-9]\+[.][0-9]\+\([_-][a-z0-9][-.a-z0-9]*\)\?$' | tee -a $${tags_file}
- echo ${DRONE_TAG} | grep -o -e '^[0-9]\+[.][0-9]\+[.][0-9]\+' | tee -a $${tags_file}
- cat $${tags_file} | xargs echo | tr '[:blank:]' ',' | tr -d '\n' | tee .tags && echo
- name: publish-image-1
image: plugins/docker
when:
event:
- tag
settings:
debug: true
build_args:
- git_commit=${DRONE_COMMIT}
username:
from_secret: docker_username
password:
from_secret: docker_password
repo: opertusmundi/bpm-worker
mirror: http://registry-mirror:5000
#- name: publish-image-2
# image: plugins/docker
# when:
# event:
# - tag
# settings:
# debug: true
# build_args:
# - git_commit=${DRONE_COMMIT}
# username:
# from_secret: registry_username
# password:
# from_secret: registry_password
# repo: registry-dev-1-opertusmundi:30474/opertusmundi/bpm-worker
# mirror: http://registry-mirror:5000
# registry: registry-dev-1-opertusmundi:30474
#
# Services
#
services:
- name: postgres-1
image: postgres:10.14-alpine
environment:
POSTGRES_PASSWORD:
from_secret: database_postgres_password
#
# Volumes
#
volumes:
- name: maven-repo
temp: {}