-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
46 lines (41 loc) · 1.4 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
image: gradle:alpine
before_script:
- GRADLE_USER_HOME="$(pwd)/.gradle"
- export GRADLE_USER_HOME
stages:
- test
- build
- deploy
variables:
SERVER_SSH_PRIVATE_KEY: "$SERVER_SSH_PRIVATE_KEY"
# Make Project
build:
interruptible: true
stage: build
script:
- ./gradlew build -x test
# Run all tests, if any fails, interrupt the pipeline(fail it)
test:
interruptible: true
stage: test
script:
- apk update && apk add openssh-client
- echo "$SERVER_SSH_PRIVATE_KEY" > deploy_key # Save the SSH key to a file
- chmod 600 deploy_key # Set correct permissions
- eval "$(ssh-agent -s)" # Start the SSH agent
- ssh-add deploy_key # Add the SSH key to the agent
- ssh -o StrictHostKeyChecking=no -i deploy_key [email protected] 'cd ~/Dev/eventichs_api; git checkout api; git pull; ./gradlew test'
only:
- api
deploy_to_server:
needs: [build]
stage: deploy
script:
- apk update && apk add openssh-client
- echo "$SERVER_SSH_PRIVATE_KEY" > deploy_key # Save the SSH key to a file
- chmod 600 deploy_key # Set correct permissions
- eval "$(ssh-agent -s)" # Start the SSH agent
- ssh-add deploy_key # Add the SSH key to the agent
- ssh -o StrictHostKeyChecking=no -i deploy_key [email protected] 'cd ~/Dev/eventichs_api; git checkout server-deploy; git pull; ./gradlew build -x test; fuser -k 8080/tcp; nohup ./gradlew bootRun &'
only:
- server-deploy