Skip to content

Instantly share code, notes, and snippets.

@SibeeshVenu
Created December 15, 2021 14:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SibeeshVenu/4951d95a528d6bef87cc353eeb010548 to your computer and use it in GitHub Desktop.
Save SibeeshVenu/4951d95a528d6bef87cc353eeb010548 to your computer and use it in GitHub Desktop.
parameters:
- name: azureSubscription
type: string
- name: webAppName
type: string
- name: sourceBranchTrigger
type: string
stages:
- stage: build_stage
displayName: "Build"
jobs:
- job: build_job
steps:
- task: UseDotNet@2
displayName: "Install .NET Core SDK"
inputs:
version: 6.x
performMultiLevelLookup: true
includePreviewVersions: true # Required for preview versions
- task: DotNetCoreCLI@2
displayName: "Dotnet Restore"
inputs:
command: "restore"
feedsToUse: "select"
feedRestore: "store/feedName"
projects: "**/*.csproj"
includeNuGetOrg: true
- task: DotNetCoreCLI@2
displayName: "Dotnet Build"
inputs:
projects: src.sln # solution file or project files
command: "build"
arguments: "--configuration $(buildConfiguration)"
# Publish projects to specified folder.
- task: DotNetCoreCLI@2
displayName: "Dotnet Publish"
inputs:
command: "publish"
publishWebProjects: true
projects: "**/*.csproj"
arguments: "-o $(Build.ArtifactStagingDirectory)"
zipAfterPublish: true
modifyOutputPath: true
# this code takes all the files in $(Build.ArtifactStagingDirectory) and uploads them as an artifact of your build.
- task: PublishPipelineArtifact@1
inputs:
targetPath: "$(Build.ArtifactStagingDirectory)"
artifactName: "artefactName"
- stage: publish_web_app
displayName: "Publish to web app"
dependsOn: build_stage
condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest'), or(eq(variables['Build.SourceBranch'], '${{ parameters.sourceBranchTrigger }}'), eq(variables['force_deploy'], 'true')))
jobs:
- job: publish_web_app
steps:
- checkout: none
# download the artifact drop from the previous job
- task: DownloadPipelineArtifact@2
inputs:
source: "current"
artifact: "artefactName"
path: "$(Build.ArtifactStagingDirectory)"
- task: AzureWebApp@1
inputs:
azureSubscription: ${{ parameters.azureSubscription }}
appType: "webApp"
appName: ${{ parameters.webAppName }}
package: "$(Build.ArtifactStagingDirectory)/**/*.zip"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment