-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
59 lines (55 loc) · 1.66 KB
/
.gitlab-ci.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
stages:
- package
- build
build:
stage: package
only:
refs:
- tags
- branches
except:
- master
image: harbor.corp.hongen.com/library/maven:3-jdk-8
variables:
MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository"
MAVEN_CLI_OPTS: "-s .m2/settings.xml --batch-mode"
script: "mvn $MAVEN_CLI_OPTS package -Dmaven.test.skip=true -B;ls target"
cache:
paths:
- .m2/repository/
artifacts:
paths:
- target/*.jar
docker-build:
stage: build
only:
refs:
- tags
- branches
except:
- master
script:
- export version=$CI_COMMIT_REF_NAME
- if [[ $(echo $version | grep "^v") ]];then
adapter_version="$VERSION_ADAPTER_DEV";
elif [[ $(echo $version | grep "^t") ]];then
adapter_version="$VERSION_ADAPTER_TEST";
elif [[ $(echo $version | grep "^r") ]];then
adapter_version="$VERSION_ADAPTER_PRO";
else
echo "version name is invalidate, $version, not update to k8s";
exit 0;
fi
- export app=$CI_PROJECT_NAME
- ls -al ./
- ls target
- ls /
- echo "$CI_PROJECT_NAME $CI_COMMIT_MESSAGE"
- sed -i "2a MAINTAINER $CI_COMMIT_MESSAGE" Dockerfile;grep "MAINTAINER" Dockerfile
- docker build -t harbor.corp.hongen.com/hongen/$app:$version .
- docker images | grep $app
- test -z "$(docker images | grep $app | grep $version)" && exit -1
- echo "$HARBOR_PASSWORD" | docker login harbor.corp.hongen.com --username admin --password-stdin
- docker push harbor.corp.hongen.com/hongen/$app:$version
- echo "update $app to $version for $adapter_version"
- docker run --rm harbor.corp.hongen.com/hongen/k8s-adapter:$adapter_version python3 update_deployment.py $app $version