forked from jelastic/helloworld
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
47 lines (42 loc) · 1.9 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
variables:
MAVEN_REPO: $CI_PROJECT_DIR/.m2
DOCKER_DRIVER: overlay
SPRING_PROFILES_ACTIVE: gitlab-ci
ENV_NAME: $CI_PROJECT_NAME-$GITLAB_USER_ID-$CI_JOB_ID
stages:
- build
- package
- deploy
maven-build:
image: maven:3-jdk-8
stage: build
script: "mvn -Dmaven.repo.local=$MAVEN_REPO package -B"
cache:
key: "$CI_BUILD_STAGE"
paths:
- node_modules
- .m2
- node
artifacts:
expire_in: 1 week
paths:
- target/*.war
docker-build:
stage: package
script:
- mv target/*.war ROOT.war
- docker build -t $CI_REGISTRY_IMAGE -f Dockerfile .
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker push $CI_REGISTRY_IMAGE
- docker logout $CI_REGISTRY
jelastic-deploy:
image: openjdk:8-jre
stage: deploy
script:
- curl -s ftp://ftp.jelastic.com/pub/cli/jelastic-cli-installer.sh | bash
- echo "jelastic.cli.send_err_confirm=false" >> ~/.config/jelastic/jelastic.properties
- ~/jelastic/users/authentication/signin --silent true --login $J_LOGIN --password $J_PASSWORD --platformUrl $J_PLATFORM
- res=$( ~/jelastic/environment/control/getenvinfo --silent --envName $ENV_NAME | { grep -c status || true; } )
- if [ $res -eq 0 ]; then echo "{\"env\":{\"shortdomain\":\"$ENV_NAME\"}, \"nodes\":[{\"nodeType\":\"docker\",\"nodeGroup\":\"cp\",\"extip\":false,\"count\":1,\"fixedCloudlets\":1,\"flexibleCloudlets\":16,\"docker\":{\"image\":\"${CI_PROJECT_PATH}\",\"registry\":{\"url\":\"${CI_REGISTRY}\",\"user\":\"${CI_REGISTRY_USER}\",\"password\":\"${CI_REGISTRY_PASSWORD}\"}}}]}" > params.json; cat params.json; ~/jelastic/environment/control/createenvironment --silent true --myparams params.json; fi;
- if [ $res -eq 1 ]; then ~/jelastic/environment/control/redeploycontainersbygroup --silent --envName $ENV_NAME --nodeGroup cp --tag latest --sequential true; fi;
- ~/jelastic/users/authentication/signout --silent true