1
- # yaml-language-server: $schema=https://raw.githubusercontent.com/Azure/azure-dev/main/schemas/v1.0/azure.yaml.json
1
+ trigger :
2
+ - main
2
3
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
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'
0 commit comments