Create Azure subscription and use it in pipelines and releases
Environment:Azure Cloud
Server URL:https://management.azure.com/
Scope Level: Subscription
Subscription Id:
Subscription Name:
Service Principal Id:
Credential: service principal key
Tenant ID:
Service Connection Name: subscription_name
Security: Grant access permission to all pipelines
Step1: Create Pipeline - azure-pipelines.yml - ensure auto trigger
# 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
- releases/*
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'
options: 'package -Dmaven.test.skip'
- task: PublishPipelineArtifact@1
inputs:
targetPath: '$(Pipeline.Workspace)'
artifactType: 'pipeline'
artifactName: 'drop'
Step2: Create Release - ensure auto trigger is enabled
steps:
- task: AzureRmWebAppDeployment@4
displayName: 'Azure App Service Deploy: <app_name>'
inputs:
azureSubscription: '<subscription_name>'
appType: webAppLinux
WebAppName: <app_name>
packageForLinux: '$(System.DefaultWorkingDirectory)/_<app_name_in_gitub>/drop/s/target'
RuntimeStack: 'JAVA|8-jre8'
AppSettings: '-WEBSITE_TIME_ZONE "Pacific Standard Time"'
Step3: Restart App Server
steps:
- task: AzureAppServiceManage@0
displayName: 'Restart Azure App Service: <app_name>'
inputs:
azureSubscription: '<subscription_name>'
Action: 'Restart Azure App Service'
WebAppName: <app_name>
Push code to master Repository and the check if the jar /drop/s/target (build - Continuous Integration) and then release
should trigger and move to Azure app server (Continous Deployment)
Build Pipeline >> Release
Comments
Post a Comment