-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbitbucket-pipelines.yml
79 lines (69 loc) · 2.36 KB
/
bitbucket-pipelines.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
image: ternau/bb-python:3.8-alpine
definitions:
# generic re-usable steps
steps:
- step: &envstep
# use a multiline step to set environment variables
- script: &setenv |
export IMAGE_NAME=ternau/linkeddata_api
- step: &build-test
script:
- *setenv
# generate version.py file
- export VERSION=$(python3 setup.py --version)
# build python pkg
- rm -fr dist
- python3 setup.py bdist_wheel
# TODO: build labels?
- docker build -t $IMAGE_NAME .
- docker run --rm -v $(pwd):/workdir -w /workdir -u root --entrypoint ./ci-scripts/run-tests.sh $IMAGE_NAME
# smoke test image
- ./ci-scripts/smoke-test.sh $IMAGE_NAME
services:
- docker
- postgres
- step: &build-push
script:
- *setenv
# generate version.py file
- export VERSION=$(python3 setup.py --version)
# build python pkg
- rm -fr dist
- python3 setup.py bdist_wheel
# TODO: build labels?
- docker build -t $IMAGE_NAME .
- docker run --rm -v $(pwd):/workdir -w /workdir -u root --entrypoint ./ci-scripts/run-tests.sh $IMAGE_NAME
# smoke test image
- ./ci-scripts/smoke-test.sh $IMAGE_NAME
# python pkg version may contain '+' wich is not allow in docker tag
- export IMAGE_TAG=${VERSION/+/-}
# re-tag image
- docker tag $IMAGE_NAME $IMAGE_NAME:$IMAGE_TAG
- docker login --username $DOCKER_USERNAME --password $DOCKER_PASSWORD
- docker push $IMAGE_NAME
- docker push $IMAGE_NAME:$IMAGE_TAG
services:
- docker
- postgres
# services used in pipelines
services:
postgres:
image: postgres:11
variables:
POSTGRES_PASSWORD: postgres
pipelines:
branches:
develop:
- step: *build-test
master:
- step: *build-push
tags:
'**':
- step: *build-push
pull-requests:
'**':
- step: *build-test
# tags:
# # pull image that fits this revision ?
# # what if image does not exist ? (either wrong branch or revision tagged that does not have a build? or tag and revision pushed at the same time?)
# # current new tag probably also hides old $(git revision --all) .... not sure how to recreate?