forked from dynatrace-sockshop/carts
-
Notifications
You must be signed in to change notification settings - Fork 187
/
.travis.yml
61 lines (58 loc) · 2.34 KB
/
.travis.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
sudo: true
dist: trusty
language: java
services:
- docker
before_install:
- export TZ=Europe/Vienna
- IMAGE=keptnexamples/carts
- VERSION="$(cat version)"
- DATE="$(date +'%Y%m%d.%H%M')"
- GIT_SHA="$(git rev-parse --short HEAD)"
- REPO_URL="$(git remote get-url --all origin)"
- LAST_COMMIT="$(git log -1 --oneline)"
- ./writeManifest.sh
- cat MANIFEST
- export IMAGE
- export GIT_SHA
jobs:
include:
- stage: feature/bug/hotfix/patch
# build docker images for feature/bug/hotfix/patch branches
if: branch =~ ^feature.*$ OR branch =~ ^bug.*$ OR branch =~ ^hotfix.*$ OR branch =~ ^patch.*$
script:
- echo $TRAVIS_BUILD_STAGE_NAME
- TYPE="$(echo $TRAVIS_BRANCH | cut -d'/' -f1)"
- NUMBER="$(echo $TRAVIS_BRANCH | cut -d'/' -f2)"
- ./build_multiple_versions.sh
- docker tag "${IMAGE}:${GIT_SHA}.1" "${IMAGE}:${TYPE}.${NUMBER}.${DATE}.1"
- docker tag "${IMAGE}:${GIT_SHA}.2" "${IMAGE}:${TYPE}.${NUMBER}.${DATE}.2"
- docker tag "${IMAGE}:${GIT_SHA}.3" "${IMAGE}:${TYPE}.${NUMBER}.${DATE}.3"
after_success:
- echo "$REGISTRY_PASSWORD" | docker login --username $REGISTRY_USER --password-stdin
- docker push "${IMAGE}"
- stage: release-branch
if: branch =~ ^release.*$ AND NOT type = pull_request
script:
- echo $TRAVIS_BUILD_STAGE_NAME
- ./build_multiple_versions.sh
- docker tag "${IMAGE}:${GIT_SHA}.1" "${IMAGE}:${VERSION}.1"
- docker tag "${IMAGE}:${GIT_SHA}.2" "${IMAGE}:${VERSION}.2"
- docker tag "${IMAGE}:${GIT_SHA}.3" "${IMAGE}:${VERSION}.3"
after_success:
- echo "$REGISTRY_PASSWORD" | docker login --username $REGISTRY_USER --password-stdin
- docker push "${IMAGE}"
- stage: master
if: branch = master AND NOT type = pull_request
script:
- echo $TRAVIS_BUILD_STAGE_NAME
- ./build_multiple_versions.sh
- docker tag "${IMAGE}:${GIT_SHA}.1" "${IMAGE}:${VERSION}.${DATE}.1"
- docker tag "${IMAGE}:${GIT_SHA}.2" "${IMAGE}:${VERSION}.${DATE}.2"
- docker tag "${IMAGE}:${GIT_SHA}.3" "${IMAGE}:${VERSION}.${DATE}.3"
- docker tag "${IMAGE}:${GIT_SHA}.1" "${IMAGE}:${VERSION}.latest.1"
- docker tag "${IMAGE}:${GIT_SHA}.2" "${IMAGE}:${VERSION}.latest.2"
- docker tag "${IMAGE}:${GIT_SHA}.3" "${IMAGE}:${VERSION}.latest.3"
after_success:
- echo "$REGISTRY_PASSWORD" | docker login --username $REGISTRY_USER --password-stdin
- docker push "${IMAGE}"