-
Notifications
You must be signed in to change notification settings - Fork 5
/
azure-pipelines.yml
157 lines (137 loc) · 4.81 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-datagrid-tests
type: github
name: OutSystems/outsystems-datagrid-tests
endpoint: OutSystems
trigger:
branches:
include:
- dev
variables:
SourcesDirectory: '$(Build.SourcesDirectory)'
Project: 'outsystems-datagrid'
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 GridFramework.js'
inputs:
PathtoPublish: './dist/GridFramework.js'
ArtifactName: 'GridFramework.js'
publishLocation: 'Container'
#Publish css file
- task: PublishBuildArtifacts@1
displayName: 'Publish Grid.css'
inputs:
PathtoPublish: './styles/Grid.css'
ArtifactName: 'Grid.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 GridFramework.js'
inputs:
buildType: 'current'
downloadType: 'single'
artifactName: 'GridFramework.js'
downloadPath: '$(Build.SourcesDirectory)/bin'
#Download artifact
- task: DownloadBuildArtifacts@0
displayName: 'Download Grid.css'
inputs:
buildType: 'current'
downloadType: 'single'
artifactName: 'Grid.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="OutSystemsDataGrid_"+"$(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
gridFrameworkJs = open("./bin/GridFramework.js/GridFramework.js", "rb").read()
encoded = base64.standard_b64encode(gridFrameworkJs)
gridFrameworkJs_file = encoded.decode('utf-8')
gridCSS = open("./bin/Grid.css/Grid.css", "rb").read()
encoded = base64.standard_b64encode(gridCSS)
gridCSS_file = encoded.decode('utf-8')
url = "$(updaterUrl)"
data = [
{
"ModuleName": "$(module)",
"Block": "Gridframework",
"File": gridFrameworkJs_file,
"IsCSS": False
},
{
"ModuleName": "$(module)",
"Block": "Grid",
"File": gridCSS_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)