Deploy Spring on Azure

Pre-Action

  • Register the application service on azure portal

  • Setup a virtual machine

  • Install java jdk ,jre, maven on virtual machine and setup the environment variable

Continuous Integration (CI)

# Maven
# Build your Java project and run tests with Apache Maven.
# Add steps that analyze code, save build artifacts, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/java

trigger:
- master

pool:
  vmImage: ubuntu-latest
  name: Default
  demands:
  - agent.name -equals myJarvisVm

steps:

- task: Maven@3
  inputs:
    mavenPomFile: 'pom.xml'
    publishJUnitResults: true
    testResultsFiles: '**/surefire-reports/TEST-*.xml'
    javaHomeOption: 'JDKVersion'
    mavenVersionOption: 'Default'
    mavenAuthenticateFeed: false
    effectivePomSkip: false
    sonarQubeRunAnalysis: false
- task: CopyFiles@2
  inputs:
    SourceFolder: 'target'
    Contents: '*.war'
    TargetFolder: '$(Build.ArtifactStagingDirectory)'
- task: PublishBuildArtifacts@1
  inputs:
    PathtoPublish: '$(Build.ArtifactStagingDirectory)'
    ArtifactName: 'drop'
    publishLocation: 'Container'
  • Install maven dependency

  • Copy the war file into artifact directory

  • Make the directory as a artifact

Continuous Deployment (CD)

Result

Last updated

Was this helpful?