I am trying to deploy a simple spring boot application via the Azure Yml pipeline. the deployment is successful but the URL only shows the default Microsoft webpage and says I need to deploy the code. in the pipeline, my artifact is published, but not consumed. the artifact is packaged as .jar file. app service uses zip deployment. i don't know how to make sure the artifact is packaged as zip , not jar.
trigger:
- master
variables:
azureSubscription: 'xxxxxxx'
webAppName: 'yyyyyyy'
stages:
- stage: BuildApplication
jobs:
- job: Build
pool:
vmImage: ubuntu-latest
steps:
- task: Maven@3
inputs:
mavenPomFile: 'pom.xml'
mavenOptions: '-Xmx3072m'
javaHomeOption: 'JDKVersion'
jdkVersionOption: '1.8'
jdkArchitectureOption: 'x64'
publishJUnitResults: true
testResultsFiles: '**/surefire-reports/TEST-*.xml'
goals: 'package'
- task: CopyFiles@2
inputs:
targetFolder: '$(Build.ArtifactStagingDirectory)'
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'drop'
publishLocation: 'Container'
- stage: DeployApplication
jobs:
- job: Deploy
pool:
vmImage: ubuntu-latest
steps:
- task: DownloadBuildArtifacts@1
inputs:
buildType: 'current'
downloadType: 'single'
artifactName: 'drop'
downloadPath: '$(System.ArtifactsDirectory)'
- task: AzureRmWebAppDeployment@4
displayName: 'Azure Web App Deploy: webApp'
inputs:
ConnectionType: 'AzureRM'
azureSubscription: $(azureSubscription)
appType: 'webApp'
WebAppName: $(webAppName)
packageForLinux: '$(System.ArtifactsDirectory)/**/*.zip'
CodePudding user response:
You could add one more task on your BuildApplication stage to zip your output of the build step.
For example you could use the Archive files task and specify the folder on which the .jar files are located. You should change the rootFolderOrFile variable. The zip output will be located on $(Build.ArtifactStagingDirectory)' with the name '$(Build.BuildId).zip
As you publish your ArtifactStagingDirectory inside this folder your BuildId.zip will contain your files. The deployment step should work without additional changes.
- task: ArchiveFiles@2
inputs:
rootFolderOrFile: '$(Build.ArtifactStagingDirectory)'
includeRootFolder: true
archiveType: 'zip'
archiveFile: '$(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip'
replaceExistingArchive: true
CodePudding user response:
Well if your application is maven based, you should get jar/war file.
step1:- Rename the file as ROOT.war/ROOT.jar.
step2:- change deploy webapp task as below.
packageForLinux: '$(System.ArtifactsDirectory)/**/*.war'
packageForLinux: '$(System.ArtifactsDirectory)/**/*.jar'
based on your artifact output.
