ci: delete Postgres DB container after tests run

Otherwise we end up with leftover containers hanging around:
```
admin@linux-03.he-eu-hel1.ci.devel:~ % d ps -a
CONTAINER ID   NAMES                IMAGE                 CREATED          STATUS
6c683f3083bf   boring_yonath        postgres:9.6-alpine   20 minutes ago   Created
b3d462925a91   dazzling_albattani   postgres:9.6-alpine   7 days ago       Created
```

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2023-02-21 13:25:50 +01:00
parent c786528965
commit 78c677742e
No known key found for this signature in database
GPG Key ID: FE65CD384D5BF7B4
1 changed files with 9 additions and 3 deletions

View File

@ -23,6 +23,7 @@ pipeline {
environment {
TARGET = 'tests'
DB_CONT = 'status-go-test-db'
TMPDIR = "${WORKSPACE_TMP}"
GOPATH = "${WORKSPACE_TMP}/go"
PATH = "${PATH}:${GOPATH}/bin"
@ -62,12 +63,17 @@ pipeline {
stage('Unit Tests') {
steps { script {
docker.image('postgres:9.6-alpine').withRun(
'-e POSTGRES_HOST_AUTH_METHOD=trust -p 5432:5432'
) { c ->
db = docker.image('postgres:9.6-alpine').withRun([
"--name=${DB_CONT}",
'--env=POSTGRES_HOST_AUTH_METHOD=trust',
'--publish=5432:5432',
].join(' ')) { c ->
nix.shell('make test-unit V=1', pure: false)
}
} }
post { cleanup { /* Leftover DB containers. */
sh "docker rm ${DB_CONT} || true"
} }
}
} // stages