This repository has been archived by the owner on Oct 11, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
.travis.yml
99 lines (99 loc) · 4.24 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
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
sudo: true
dist: xenial
language: node_js
node_js:
- '10'
services:
- docker
before_install:
- export TZ=Europe/Vienna
- SERVICE_IMAGE=keptn/jenkins-service
- JENKINS_IMAGE=keptn/jenkins
- REGISTRY_USER=jbraeuer
- SERVICE_VERSION="$(cat version | tr -d '[:space:]')"
- JENKINS_VERSION="$(cat ./docker-jenkins/version | tr -d '[:space:]')"
- JENKINS_FOLDER="docker-jenkins"
- DATE="$(date +'%Y%m%d.%H%M')"
- GIT_SHA="$(git rev-parse --short HEAD)"
- echo "$REGISTRY_PASSWORD" | docker login --username $REGISTRY_USER --password-stdin
- REPO_URL="$(git remote get-url --all origin)"
- LAST_COMMIT="$(git log -1 --oneline)"
- CHANGED_FILES=($(git diff --name-only $TRAVIS_COMMIT_RANGE | paste -sd "," ) )
- echo "Changed files>$CHANGED_FILES"
- ./writeManifest.sh
- cp MANIFEST ./docker-jenkins/MANIFEST
- cat MANIFEST
- cat ./docker-jenkins/MANIFEST
- npm install
jobs:
include:
- stage: feature/bug
if: branch =~ ^feature.*$ OR branch =~ ^bug.*$ OR branch =~ ^hotfix.*$
script:
- echo $TRAVIS_BUILD_STAGE_NAME
- echo "Build jenkins-service"
- TYPE="$(echo $TRAVIS_BRANCH | cut -d'/' -f1)"
- NUMBER="$(echo $TRAVIS_BRANCH | cut -d'/' -f2)"
- docker build . -t "${SERVICE_IMAGE}:${GIT_SHA}"
- docker tag "${SERVICE_IMAGE}:${GIT_SHA}" "${SERVICE_IMAGE}:${TYPE}.${NUMBER}.${DATE}"
- docker push "${SERVICE_IMAGE}:${GIT_SHA}"
- docker push "${SERVICE_IMAGE}:${TYPE}.${NUMBER}.${DATE}"
- |
if [[ $CHANGED_FILES == *"${JENKINS_FOLDER}"* ]]; then
echo "Build Jenkins image"
cd docker-jenkins
docker build . -t "${JENKINS_IMAGE}:${GIT_SHA}"
docker tag "${JENKINS_IMAGE}:${GIT_SHA}" "${JENKINS_IMAGE}:${TYPE}.${NUMBER}.${DATE}"
docker push "${JENKINS_IMAGE}:${GIT_SHA}"
docker push "${JENKINS_IMAGE}:${TYPE}.${NUMBER}.${DATE}"
fi
- stage: develop
if: branch = develop AND NOT type = pull_request
script:
- echo $TRAVIS_BUILD_STAGE_NAME
- echo "Build jenkins-service"
- docker build . -t "${SERVICE_IMAGE}:${GIT_SHA}"
- docker tag "${SERVICE_IMAGE}:${GIT_SHA}" "${SERVICE_IMAGE}:${DATE}"
- docker tag "${SERVICE_IMAGE}:${GIT_SHA}" "${SERVICE_IMAGE}:latest"
- docker push "${SERVICE_IMAGE}:${GIT_SHA}"
- docker push "${SERVICE_IMAGE}:${DATE}"
- docker push "${SERVICE_IMAGE}:latest"
- |
if [[ $CHANGED_FILES == *"${JENKINS_FOLDER}"* ]]; then
echo "Build Jenkins image"
cd docker-jenkins
docker build . -t "${JENKINS_IMAGE}:${GIT_SHA}"
docker tag "${JENKINS_IMAGE}:${GIT_SHA}" "${JENKINS_IMAGE}:${DATE}"
docker tag "${JENKINS_IMAGE}:${GIT_SHA}" "${JENKINS_IMAGE}:latest"
docker push "${JENKINS_IMAGE}:${GIT_SHA}"
docker push "${JENKINS_IMAGE}:${DATE}"
docker push "${JENKINS_IMAGE}:latest"
fi
- stage: release-branch
if: branch =~ ^release.*$ AND NOT type = pull_request
script:
- echo $TRAVIS_BUILD_STAGE_NAME
- docker build . -t "${SERVICE_IMAGE}:${GIT_SHA}"
- docker tag "${SERVICE_IMAGE}:${GIT_SHA}" "${SERVICE_IMAGE}:${SERVICE_VERSION}.${DATE}"
- docker tag "${SERVICE_IMAGE}:${GIT_SHA}" "${SERVICE_IMAGE}:${SERVICE_VERSION}.latest"
- docker push "${SERVICE_IMAGE}:${GIT_SHA}"
- docker push "${SERVICE_IMAGE}:${SERVICE_VERSION}.${DATE}"
- docker push "${SERVICE_IMAGE}:${SERVICE_VERSION}.latest"
- echo "Build Jenkins image"
- cd docker-jenkins
- docker build . -t "${JENKINS_IMAGE}:${GIT_SHA}"
- docker tag "${JENKINS_IMAGE}:${GIT_SHA}" "${JENKINS_IMAGE}:${JENKINS_VERSION}.${DATE}"
- docker tag "${JENKINS_IMAGE}:${GIT_SHA}" "${JENKINS_IMAGE}:${JENKINS_VERSION}.latest"
- docker push "${JENKINS_IMAGE}:${GIT_SHA}"
- docker push "${JENKINS_IMAGE}:${JENKINS_VERSION}.${DATE}"
- docker push "${JENKINS_IMAGE}:${JENKINS_VERSION}.latest"
- stage: master
if: branch = master AND NOT type = pull_request
script:
- echo $TRAVIS_BUILD_STAGE_NAME
- docker build . -t "${SERVICE_IMAGE}:${SERVICE_VERSION}"
- docker push "${SERVICE_IMAGE}:${SERVICE_VERSION}"
- echo "Build Jenkins image"
- cd docker-jenkins
- docker build . -t "${JENKINS_IMAGE}:${JENKINS_VERSION}"
- docker push "${JENKINS_IMAGE}:${JENKINS_VERSION}"