Skip to content

Commit fde8ada

Browse files
committed
add pipeline file app-ci.yaml and reverted change to azure.yaml.
1 parent a4720ef commit fde8ada

File tree

2 files changed

+144
-79
lines changed

2 files changed

+144
-79
lines changed

app-ci.yaml

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
trigger:
2+
- main
3+
4+
pool:
5+
vmImage: 'ubuntu-latest'
6+
7+
stages:
8+
- stage: Build
9+
jobs:
10+
- job: WebApp
11+
steps:
12+
- task: Npm@1
13+
displayName: 'Npm Install'
14+
inputs:
15+
command: 'install'
16+
workingDir: 'app/frontend/'
17+
- task: Npm@1
18+
displayName: 'Npm run build'
19+
inputs:
20+
command: 'custom'
21+
workingDir: 'app/frontend/'
22+
customCommand: 'run build'
23+
24+
- task: Maven@4
25+
displayName: 'Build springboot app'
26+
inputs:
27+
mavenPomFile: 'app/backend/pom.xml'
28+
goals: 'package'
29+
javaHomeOption: 'JDKVersion'
30+
jdkVersionOption: '1.17'
31+
jdkArchitectureOption: 'x64'
32+
publishJUnitResults: true
33+
mavenVersionOption: 'Default'
34+
mavenAuthenticateFeed: false
35+
effectivePomSkip: false
36+
sonarQubeRunAnalysis: false
37+
38+
# get jar name from pom.xml and set it as output variable so Deploy job and use it
39+
- task: Bash@3
40+
displayName: 'Get jar file name from pom.xml'
41+
inputs:
42+
targetType: 'inline'
43+
script: |
44+
version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
45+
artifactId=$(mvn help:evaluate -Dexpression=project.artifactId -q -DforceStdout)
46+
echo "##vso[task.setvariable variable=jarfilename;isOutput=true]$artifactId-$version"
47+
workingDirectory: 'app/backend/'
48+
name: pomvariable
49+
50+
# copy final jar file to target folder
51+
- task: CopyFiles@2
52+
displayName: 'Copy jar file'
53+
inputs:
54+
Contents: 'app/backend/target/$(pomvariable.jarfilename).jar'
55+
TargetFolder: '$(Build.ArtifactStagingDirectory)'
56+
57+
# upload the artifact to spring-boot-app container
58+
- task: PublishBuildArtifacts@1
59+
displayName: 'Upload springboot app artifacts'
60+
inputs:
61+
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
62+
ArtifactName: 'spring-boot-app'
63+
publishLocation: 'Container'
64+
65+
- stage: DeployDev
66+
condition: eq(variables['Build.SourceBranch'], 'refs/heads/dev')
67+
dependsOn: Build
68+
variables:
69+
buildjarfilename: $[ stageDependencies.Build.WebApp.outputs['pomvariable.jarfilename'] ]
70+
jobs:
71+
- deployment: DeploySpringbootApp
72+
displayName: 'Azure Web App'
73+
variables:
74+
buildjarfilename: $[ stageDependencies.Build.WebApp.outputs['pomvariable.jarfilename'] ]
75+
environment: 'dev'
76+
strategy:
77+
runOnce:
78+
deploy:
79+
steps:
80+
- task: AzureWebApp@1
81+
displayName: 'Azure Web App'
82+
inputs:
83+
azureSubscription: '<azureSubscriptionServiceConnection>'
84+
appType: 'webAppLinux'
85+
appName: '<appServiceName>
86+
package: '$(Pipeline.Workspace)/**/$(buildjarfilename).jar'
87+
runtimeStack: 'JAVA|17-java17'
88+
startUpCommand: 'java -jar /home/site/wwwroot/$(buildjarfilename).jar'
89+
90+
- stage: DeployProd
91+
condition: eq(variables['Build.SourceBranch'], 'refs/heads/main')
92+
dependsOn: Build
93+
variables:
94+
buildjarfilename: $[ stageDependencies.Build.WebApp.outputs['pomvariable.jarfilename'] ]
95+
jobs:
96+
- deployment: DeploySpringbootApp
97+
displayName: 'Azure Web App'
98+
environment: 'prod'
99+
strategy:
100+
runOnce:
101+
deploy:
102+
steps:
103+
- task: AzureWebApp@1
104+
displayName: 'Azure Web App'
105+
inputs:
106+
azureSubscription: '<azureSubscriptionServiceConnection>'
107+
appType: 'webAppLinux'
108+
appName: '<appServiceName>'
109+
package: '$(Pipeline.Workspace)/**/$(buildjarfilename).jar'
110+
runtimeStack: 'JAVA|17-java17'
111+
startUpCommand: 'java -jar /home/site/wwwroot/$(buildjarfilename).jar'

azure.yaml

Lines changed: 33 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,34 @@
1-
trigger:
2-
- main
1+
# yaml-language-server: $schema=https://raw.githubusercontent.com/Azure/azure-dev/main/schemas/v1.0/azure.yaml.json
32

4-
pool:
5-
vmImage: 'ubuntu-latest'
6-
7-
jobs:
8-
- job: Build
9-
steps:
10-
- task: Npm@1
11-
displayName: 'Npm Install'
12-
inputs:
13-
command: 'install'
14-
workingDir: 'app/frontend/'
15-
- task: Npm@1
16-
displayName: 'Npm run build'
17-
inputs:
18-
command: 'custom'
19-
workingDir: 'app/frontend/'
20-
customCommand: 'run build'
21-
22-
# build springboot app with Maven
23-
- task: Maven@4
24-
displayName: 'Build Springboot App'
25-
inputs:
26-
mavenPomFile: 'app/backend/pom.xml'
27-
goals: 'package'
28-
javaHomeOption: 'JDKVersion'
29-
jdkVersionOption: '1.17'
30-
jdkArchitectureOption: 'x64'
31-
publishJUnitResults: false
32-
mavenVersionOption: 'Default'
33-
mavenAuthenticateFeed: false
34-
effectivePomSkip: false
35-
sonarQubeRunAnalysis: false
36-
37-
# get jar name from pom.xml and set it as output variable so Deploy job and use it
38-
- powershell: |
39-
[xml]$pomXml = Get-Content .\app\backend\pom.xml
40-
$version=$pomXml.project.version
41-
$artifactId=$pomXml.project.artifactId
42-
Write-Host "##vso[task.setvariable variable=jarfilename;isOutput=true]$artifactId-$version"
43-
name: pomvariable
44-
45-
# copy final jar file to target folder
46-
- task: CopyFiles@2
47-
displayName: 'Copy Content'
48-
inputs:
49-
Contents: 'app/backend/target/$(pomvariable.jarfilename).jar'
50-
TargetFolder: '$(Build.ArtifactStagingDirectory)'
51-
52-
# upload the artifact to spring-boot-app container
53-
- task: PublishBuildArtifacts@1
54-
displayName: 'Publish Springboot App'
55-
inputs:
56-
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
57-
ArtifactName: 'spring-boot-app'
58-
publishLocation: 'Container'
59-
60-
- job: Deploy
61-
dependsOn: Build
62-
variables:
63-
buildjarfilename: $[ dependencies.Build.outputs['pomvariable.jarfilename'] ]
64-
steps:
65-
# download the artifact spring-boot-app from the previous job
66-
- task: DownloadPipelineArtifact@2
67-
inputs:
68-
source: 'current'
69-
artifact: 'spring-boot-app'
70-
path: '$(Pipeline.Workspace)'
71-
72-
# deploy to web app
73-
- task: AzureWebApp@1
74-
inputs:
75-
azureSubscription: '##Use your own subscription via Service connections##'
76-
appType: 'webAppLinux'
77-
appName: '##Use your own web app name##'
78-
package: '$(Pipeline.Workspace)/**/$(buildjarfilename).jar'
79-
runtimeStack: 'JAVA|17-java17'
80-
startUpCommand: 'java -jar /home/site/wwwroot/$(buildjarfilename).jar'
3+
name: azure-search-openai-demo
4+
metadata:
5+
6+
services:
7+
backend:
8+
project: ./app/backend
9+
language: java
10+
host: appservice
11+
hooks:
12+
prepackage:
13+
windows:
14+
shell: pwsh
15+
run: cd ../frontend;npm install;npm run build
16+
interactive: true
17+
continueOnError: false
18+
posix:
19+
shell: sh
20+
run: cd ../frontend;npm install;npm run build
21+
interactive: true
22+
continueOnError: false
23+
hooks:
24+
postprovision:
25+
windows:
26+
shell: pwsh
27+
run: ./scripts/prepdocs.ps1
28+
interactive: true
29+
continueOnError: false
30+
posix:
31+
shell: sh
32+
run: ./scripts/prepdocs.sh
33+
interactive: true
34+
continueOnError: false

0 commit comments

Comments
 (0)