-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathazure-pipelines.yml
172 lines (149 loc) · 6.07 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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
# 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
trigger:
- master
pool:
vmImage: ubuntu-latest
stages:
- stage: Build
displayName: Build Gateway
jobs:
- job: Build
steps:
- task: Gradle@2
displayName: Building Gateway
inputs:
workingDirectory: ''
gradleWrapperFile: 'gradlew'
gradleOptions: '-Xmx3072m'
# javaHomeOption: 'JDKVersion'
# jdkVersionOption: '1.8'
jdkArchitectureOption: 'x64'
publishJUnitResults: true
testResultsFiles: '**/TEST-*.xml'
tasks: 'build'
- task: PowerShell@2
name: Manage
displayName: Manage before artifacting
inputs:
targetType: 'inline'
script: |
$items = Get-ChildItem -Path $(Build.SourcesDirectory)/build/libs | Where-Object { $_.BaseName -match "plain" }
foreach ($item in $items)
{
Remove-Item $item
}
- task: PowerShell@2
name: Details
displayName: Get Filename
inputs:
targetType: 'inline'
script: |
$text = Get-Content .\build.gradle.kts
$package = $( $text | Where-Object { $_ -match "^base.archivesBaseName =" }).Replace("base.archivesBaseName = ", "").Trim('"')
$version = $( $text | Where-Object { $_ -match "^version =" }).Replace("version = ", "").Trim('"')
$packageName = $($package + "-" + $version + ".jar")
Write-Host "##vso[task.setvariable variable=packageName;]$packageName"
Write-Host "##vso[task.setvariable variable=version;]$version"
[pscustomobject]@{
version = $version
packageName = $packageName
package = $package
} | ConvertTo-Json | Out-File -FilePath $(Build.SourcesDirectory)/build/libs/build.json
- task: PowerShell@2
enabled: false
displayName: Debug
inputs:
targetType: 'inline'
script: |
Write-Host "Env " $env:PACKAGENAME -ErrorAction Continue
Get-ChildItem Env:* | Select-Object -Property Name,Value
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(Build.SourcesDirectory)/build/libs'
ArtifactName: 'package'
publishLocation: 'Container'
- stage: Docker
displayName: Build Docker image
jobs:
- job: Image
steps:
- task: DownloadBuildArtifacts@0
inputs:
buildType: 'current'
downloadType: 'single'
artifactName: 'package'
downloadPath: '$(Build.SourcesDirectory)'
- task: PowerShell@2
displayName: Prepare data
inputs:
targetType: 'inline'
script: |
$build = Get-Content -Path $(Build.SourcesDirectory)/package/build.json | ConvertFrom-Json
Write-Host $build
$packageName = $build.packageName
$version = $build.version
Write-Host "Package Name => " $packageName
Write-Host "Version => " $version
Write-Host "###vso[task.setvariable variable=packageName;]$packageName"
Write-Host "###vso[task.setvariable variable=version;]$version"
if ($build.packageName -match "SNAPSHOT") {
Write-Host "##vso[task.setvariable variable=releaseVersion;]$False"
} else {
Write-Host "##vso[task.setvariable variable=releaseVersion;]$True"
}
- task: PowerShell@2
enabled: true
displayName: Debug
inputs:
targetType: 'inline'
script: |
Write-Host "Env " $env:PACKAGENAME -ErrorAction Continue
Get-ChildItem Env:* | Select-Object -Property Name,Value
- task: PowerShell@2
displayName: Align with imaging
inputs:
targetType: inline
script: |
Get-ChildItem -Path $(Build.SourcesDirectory)/package
$file = "$(Build.SourcesDirectory)/package/$env:PACKAGENAME"
Write-Host "File " $file
Rename-Item -Path $(Build.SourcesDirectory)/package/$env:PACKAGENAME $(targetName).jar
- task: PowerShell@2
displayName: TestArray
condition: eq(variables['releaseVersion'], 'False')
inputs:
targetType: inline
script: |
Write-Host "Build variant " $env:RELEASEVERSION
- task: PowerShell@2
displayName: TestParameter
condition: eq(variables.releaseVersion, 'False')
inputs:
targetType: inline
script: |
Write-Host "Build variant " $env:RELEASEVERSION
- task: Docker@2
enabled: true
condition: eq(variables['releaseVersion'], 'False')
inputs:
containerRegistry: 'DockerHub'
repository: 'bskjon/cloud-gateway'
command: 'buildAndPush'
Dockerfile: '$(Build.SourcesDirectory)/Dockerfile'
tags: |
kotlin-snapshot
kotlin-$(version)
- task: Docker@2
enabled: true
condition: eq(variables['releaseVersion'], 'True')
inputs:
containerRegistry: 'DockerHub'
repository: 'bskjon/cloud-gateway'
command: 'buildAndPush'
Dockerfile: '$(Build.SourcesDirectory)/Dockerfile'
tags: |
kotlin-$(version)
kotlin-latest