-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathazure-pipelines.yml
103 lines (99 loc) · 3.04 KB
/
azure-pipelines.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
100
101
102
103
variables:
devops_rootdir: /opt/solid
devops_dir: $(devops_rootdir)/backend
backend_dir: /opt/backend/backend-$(Build.SourceBranchName)
backend_rooturl: backend.solid.wirackern.de
env_file: .env
trigger:
branches:
include:
- master
- quarkus
stages:
- stage: app
jobs:
- job: app
pool:
vmImage: 'ubuntu-latest'
steps:
- task: Maven@3
inputs:
mavenPomFile: 'pom.xml'
mavenOptions: '-Xmx3072m'
javaHomeOption: 'JDKVersion'
jdkVersionOption: '1.8'
jdkArchitectureOption: 'x64'
publishJUnitResults: true
testResultsFiles: '**/surefire-reports/TEST-*.xml'
goals: 'package'
- task: GithubRelease@0
displayName: 'Remove GitHub old release'
continueOnError: true
inputs:
gitHubConnection: github.com_serapas
repositoryName: '$(Build.Repository.Name)'
action: delete
tagSource: manual
tag: $(Build.SourceBranchName)
- task: GithubRelease@0
displayName: 'Create GitHub Release'
inputs:
gitHubConnection: github.com_serapas
tagSource: manual
tag: $(Build.SourceBranchName)
repositoryName: '$(Build.Repository.Name)'
assets: |
target/solid-backend.jar
- stage: image
dependsOn:
- app
condition: succeeded('app')
jobs:
- job: image
steps:
- task: Docker@2
displayName: Login to Docker Hub
inputs:
command: login
containerRegistry: dockerhub
- task: Docker@2
displayName: build
inputs:
command: build
arguments: --build-arg branch=$(Build.SourceBranchName)
repository: wirvsvirussolid/solid
tags: |
backend-$(Build.SourceBranchName)
- task: Docker@2
displayName: push
inputs:
command: push
containerRegistry: dockerhub
repository: wirvsvirussolid/solid
tags: |
backend-$(Build.SourceBranchName)
- stage: deploy
dependsOn:
- image
jobs:
- deployment: VMDeploy
displayName: deploy
environment:
name: SoliD
resourceType: VirtualMachine
strategy:
runOnce:
deploy:
steps:
- task: Bash@3
inputs:
targetType: 'inline'
script: |
sudo mkdir -p $(backend_dir)
sudo rsync -av $(devops_dir)/ $(backend_dir)/
cd $(backend_dir)
if [ '$(Build.SourceBranchName)' != 'master' ]; then NEW_HOSTNAME=$(Build.SourceBranchName).$(backend_rooturl); else NEW_HOSTNAME=$(backend_rooturl); fi; sudo sed -i -e "s/BACKEND_VIRTUAL_HOST.*$/BACKEND_VIRTUAL_HOST=$NEW_HOSTNAME/" $(env_file)
sudo sed -i -e "s/BACKEND_BRANCH.*$/BACKEND_BRANCH=$(Build.SourceBranchName)/" $(env_file)
sudo docker-compose down
sudo docker-compose pull --parallel
sudo docker-compose up -d