-
Notifications
You must be signed in to change notification settings - Fork 0
/
azure-pipelines.yml.old
214 lines (196 loc) · 6.45 KB
/
azure-pipelines.yml.old
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
# Starter pipeline
# Start with a minimal pipeline that you can customize to build and deploy your code.
# Add steps that build, run tests, deploy, and more:
# https://aka.ms/yaml
pr:
branches:
include:
- '*' # must quote since "*" is a YAML reserved character; we want a string
#pr: none
trigger:
branches:
include:
- master
pool:
vmImage: ubuntu-latest
resources:
repositories:
- repository: MyGitHub_splitman2run # The name used to reference this repository in the checkout step
type: github
endpoint: lezhumain
name: lezhumain/SplitMan2-run
variables:
- group: var_groupe
- name: IMAGE
value: splitman2
- name: SREPO
value: SplitMan2
stages:
- stage: Build
jobs:
- job: Build_Docker_Containers
steps:
- checkout: self
- checkout: MyGitHub_splitman2run
- task: NodeTool@0
inputs:
versionSource: 'spec'
versionSpec: '20.x'
- task: DownloadSecureFile@1
name: sslCert
displayName: 'Download cert'
inputs:
secureFile: 'letsencrypt.crt'
- task: DownloadSecureFile@1
name: sslKey
displayName: 'Download key'
inputs:
secureFile: 'letsencrypt.key'
- script: |
if [ -z "$IMAGE" ]; then
exit 1
fi
displayName: 'Test variables'
- script: |
cd "$SREPO"
TARGET_DIR="/home/$(whoami)/.ssl"
echo "TARGET_DIR: $TARGET_DIR"
mkdir -p "$TARGET_DIR"
sudo cp $(sslCert.secureFilePath) "$TARGET_DIR/letsencrypt.crt"
sudo cp $(sslKey.secureFilePath) "$TARGET_DIR/letsencrypt.key"
sudo chown -R "$(whoami)" "$TARGET_DIR"
chmod 600 "$TARGET_DIR"/*
displayName: 'Prepare SSL key and cert'
- script: |
cd "$SREPO"
bash ../SplitMan2-run/run_docker_e2e.sh "$DEBIAN_IP" "https" "$SREPO"
docker save "$IMAGE" -o "$(Build.ArtifactStagingDirectory)/$IMAGE.tar"
echo "Saved tar:"
ls -ald "$(Build.ArtifactStagingDirectory)/$IMAGE.tar"
env:
MONGO_USER: $(MONGO_USER)
MONGO_PASS: $(MONGO_PASS)
DEBIAN_IP: $(DEBIAN_IP)
displayName: 'Build containers'
- script: |
cp "SplitMan2-run/prepare_azure_ssh.sh" "$(Build.ArtifactStagingDirectory)/"
cp "SplitMan2-run/setup_azure_ssh.sh" "$(Build.ArtifactStagingDirectory)/"
echo "Saved scripts"
ls -alh "$(Build.ArtifactStagingDirectory)/"
displayName: 'Copy SSH script to artifacts'
- publish: '$(Build.ArtifactStagingDirectory)/$(IMAGE).tar'
displayName: 'Publish tar image'
artifact: splitman2_tar
- publish: '$(Build.ArtifactStagingDirectory)/prepare_azure_ssh.sh'
displayName: 'Publish prepare script'
artifact: prepare_azure_ssh
- publish: '$(Build.ArtifactStagingDirectory)/setup_azure_ssh.sh'
displayName: 'Publish SSH script'
artifact: setup_azure_ssh
# - task: DownloadSecureFile@1
# name: sshKey
# displayName: 'Download SSH key'
# inputs:
# secureFile: 'id_releaseUser'
#
# - script: |
# chmod +x SplitMan2-run/*.sh
# bash SplitMan2-run/prepare_azure_ssh.sh "$(sshKey.secureFilePath)"
# displayName: 'Prepare SSH key'
#
# - script: |
# . SplitMan2-run/setup_azure_ssh.sh
# cat "$HOME/.ssh/config"
# env:
# DEBIAN_USER: $(DEBIAN_USER)
# DEBIAN_IP: $(DEBIAN_IP_REAL)
# displayName: 'Setup SSH access'
#
# - script: |
# scp "$(Build.ArtifactStagingDirectory)/$IMAGE.tar" "ovhVM_rel:${DEBIAN_PATH}"
# env:
# DEBIAN_PATH: $(DEBIAN_PATH)
# displayName: 'Save containers'
#
#
# - stage: Deploy
# jobs:
# - job: Deploy_Docker_Containers
# steps:
# - checkout: self
# - checkout: MyGitHub_splitman2run
#
# - task: DownloadSecureFile@1
# name: sshKey
# displayName: 'Download SSH key'
# inputs:
# secureFile: 'id_releaseUser'
#
# - script: |
# chmod +x SplitMan2-run/*.sh
# bash SplitMan2-run/prepare_azure_ssh.sh "$(sshKey.secureFilePath)"
# displayName: 'Prepare SSH key'
#
# - script: |
# cat SplitMan2-run/setup_azure_ssh.sh
# . SplitMan2-run/setup_azure_ssh.sh
# cat "$HOME/.ssh/config"
# env:
# DEBIAN_USER: $(DEBIAN_USER)
# DEBIAN_IP: $(DEBIAN_IP_REAL)
# displayName: 'Setup SSH access'
#
# - download: current
# artifact: splitman2_tar
#
# - script: |
# ls -ald "$(Pipeline.Workspace)/splitman2_tar/$IMAGE.tar"
#
# - script: |
# bash SplitMan2-run/backup_current.sh
# env:
# DEBIAN_PATH: $(DEBIAN_PATH)
# displayName: 'Backup current'
#
# - script: |
# ssh -oBatchMode=yes "ovhVM_rel" bash << EOF
# cd "$DEBIAN_PATH"
# docker ps
# docker images
# docker load -i "$IMAGE.tar"
# docker images
# docker ps
# EOF
# env:
# DEBIAN_PATH: $(DEBIAN_PATH)
# displayName: 'Update containers'
#
# - script: |
# cd SplitMan2-run
# bash run_containers.sh
# env:
# MONGO_USER: $(MONGO_USER)
# MONGO_PASS: $(MONGO_PASS)
# DEBIAN_PATH: $(DEBIAN_PATH)
# displayName: 'Run containers'
#
# - stage: Run_E2E
# displayName: Build E2E image
# jobs:
# - job: Run_E2E
# displayName: Build
# pool:
# vmImage: ubuntu-latest
# steps:
# - task: Docker@2
# inputs:
# command: build
# dockerfile: '**/Dockerfile_e2e'
# tags: |
# $(tag)
# arguments: '--build-arg IP="splitman2.fr:8081" -t splitman2_e2e'
# displayName: Build E2E image
#
# - script: |
# docker run splitman2_e2e
# displayName: 'Run E2E image'