-
Notifications
You must be signed in to change notification settings - Fork 8
/
azure-pipelines.yml
157 lines (137 loc) · 4.76 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
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
# File: azure-pipelines.yml
resources:
repositories:
- repository: outsystems-maps-tests
type: github
name: OutSystems/outsystems-maps-tests
endpoint: OutSystems
trigger:
branches:
include:
- dev
variables:
SourcesDirectory: '$(Build.SourcesDirectory)'
Project: 'outsystems-maps'
BuildConfiguration: 'Release'
Config: '--configuration=$(BuildConfiguration)'
TagName: 'v$(Build.BuildNumber)'
CurrentBranchName: $(Build.SourceBranchName)
SourceBranchName: $(System.PullRequest.SourceBranch)
stages:
- stage: Build
displayName: 'Build'
jobs:
- job: Build
displayName: 'Build Job'
timeoutInMinutes: 8
pool:
vmImage: 'windows-latest'
steps:
#Install dependencies
- task: Npm@1
displayName: 'npm install'
inputs:
workingDir: './'
verbose: false
#Compile typescript files
- task: Npm@1
displayName: 'npm run build'
inputs:
workingDir: './'
command: custom
verbose: false
customCommand: 'run build'
#Publish compiled file
- task: PublishBuildArtifacts@1
displayName: 'Publish OutSystemsMaps.js'
inputs:
PathtoPublish: './dist/OutSystemsMaps.js'
ArtifactName: 'OutSystemsMaps.js'
publishLocation: 'Container'
#Publish css file
- task: PublishBuildArtifacts@1
displayName: 'Publish Map.css'
inputs:
PathtoPublish: './styles/Map.css'
ArtifactName: 'Map.css'
publishLocation: 'Container'
- stage: Deploy
#Only run if not in dev branch
condition: ne(variables['Build.SourceBranchName'], 'dev')
displayName: 'Deploy'
jobs:
- job: Deploy
displayName: 'Deploy Job'
timeoutInMinutes: 20
pool:
vmImage: 'windows-latest'
steps:
#Download artifact
- task: DownloadBuildArtifacts@0
displayName: 'Download OutSystemsMaps.js'
inputs:
buildType: 'current'
downloadType: 'single'
artifactName: 'OutSystemsMaps.js'
downloadPath: '$(Build.SourcesDirectory)/bin'
#Download artifact
- task: DownloadBuildArtifacts@0
displayName: 'Download Map.css'
inputs:
buildType: 'current'
downloadType: 'single'
artifactName: 'Map.css'
downloadPath: '$(Build.SourcesDirectory)/bin'
#Define Python version
- task: UsePythonVersion@0
displayName: 'Use Python 3.8'
inputs:
versionSpec: 3.8
addToPath: true
#Install tools
- script: python -m pip install --upgrade pip requests pybase64
displayName: 'Install tools'
#Format branch name
- powershell: |
$moduleName="OutSystemsMaps_"+"$(System.PullRequest.SourceBranch)"-replace '-', ''
Write-Host "##vso[task.setvariable variable=module;]$moduleName"
#Run Python script to publish code
- task: PythonScript@0
displayName: 'Send built files to Server'
inputs:
scriptSource: 'inline'
script: |
import requests
import base64
mapsJs = open("./bin/OutSystemsMaps.js/OutSystemsMaps.js", "rb").read()
encoded = base64.standard_b64encode(mapsJs)
mapsJs_file = encoded.decode('utf-8')
mapCSS = open("./bin/Map.css/Map.css", "rb").read()
encoded = base64.standard_b64encode(mapCSS)
mapCSS_file = encoded.decode('utf-8')
url = "$(updaterUrl)"
data = [
{
"ModuleName": "$(module)",
"Block": "OutSystemsMaps",
"File": mapsJs_file,
"IsCSS": False
},
{
"ModuleName": "$(module)",
"Block": "MapCSS",
"File": mapCSS_file ,
"IsCSS": True
}
]
headers = {
'Authorization': "$(auth)",
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, json = data)
print(response.text.encode('utf8'))
#Run test pipeline
- template: 'jobs/azure-pipelines-reactive.yml'
parameters:
currentBranch: $(CurrentBranchName)
sourceBranch: $(SourceBranchName)