Created
September 10, 2020 18:21
-
-
Save ralacher/e8f52fdcd3a790a4cf896d7f4b33396e to your computer and use it in GitHub Desktop.
Azure DevOps Build Pipeline Examples
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Pipeline to build, test, and package an Angular SPA | |
trigger: | |
- master | |
pool: | |
vmImage: 'windows-latest' | |
steps: | |
- task: UseNode@1 | |
inputs: | |
version: '12.x' | |
displayName: 'Install Node.js' | |
- task: Npm@1 | |
displayName: 'Install Angular CLI' | |
inputs: | |
command: 'custom' | |
customCommand: 'install -g @angular/cli' | |
- task: Npm@1 | |
displayName: 'Install Dependencies' | |
inputs: | |
command: 'install' | |
- task: Bash@3 | |
displayName: 'Angular Test and Build' | |
inputs: | |
targetType: 'inline' | |
script: | | |
ng test --no-watch --no-progress --browsers ChromeHeadless --code-coverage | |
ng build --prod | |
- task: reportgenerator@4 | |
displayName: 'Generate Code Coverage Report' | |
inputs: | |
reports: 'coverage\iRED-Web-Portal\cobertura-coverage.xml' | |
targetdir: 'coverage\iRED-Web-Portal\Reports' | |
- task: PublishTestResults@2 | |
displayName: 'Publish Test Results' | |
inputs: | |
testResultsFormat: 'JUnit' | |
testResultsFiles: '$(Build.SourcesDirectory)/reports/junit.xml' | |
searchFolder: | |
- task: PublishCodeCoverageResults@1 | |
displayName: 'Publish Code Coverage' | |
inputs: | |
codeCoverageTool: 'Cobertura' | |
summaryFileLocation: '$(Build.SourcesDirectory)\coverage\iRED-Web-Portal\cobertura-coverage.xml' | |
reportDirectory: '$(Build.SourcesDirectory)\coverage\iRED-Web-Portal\Reports' | |
- task: ArchiveFiles@2 | |
displayName: 'Archive Artifacts' | |
inputs: | |
rootFolderOrFile: '$(Build.SourcesDirectory)/dist/iRED-Web-Portal' | |
includeRootFolder: false | |
archiveType: 'zip' | |
archiveFile: '$(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip' | |
replaceExistingArchive: true | |
- task: PublishBuildArtifacts@1 | |
displayName: 'Publish Artifacts' | |
inputs: | |
PathtoPublish: '$(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip' | |
ArtifactName: 'drop' | |
publishLocation: 'Container' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Sample pipeline to build, test, and package a .NET Core application | |
# Requires NUnit, Coverlet, and ReportGenerator CLI dependencies in .csproj | |
trigger: | |
- master | |
pool: | |
vmImage: 'windows-latest' | |
steps: | |
- task: DotNetCoreCLI@2 | |
displayName: 'Restore' | |
inputs: | |
command: 'restore' | |
- task: DotNetCoreCLI@2 | |
displayName: 'Build' | |
inputs: | |
command: 'build' | |
- task: DotNetCoreCLI@2 | |
displayName: Run tests | |
inputs: | |
command: 'test' | |
arguments: /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura /p:CoverletOutput=TestResults/Coverage/ /p:ExcludeByFile=**/Functions.cs | |
- task: reportgenerator@4 | |
displayName: Generate Code Coverage Report | |
inputs: | |
targetdir: $(Build.SourcesDirectory)/tests/TestResults/Coverage/Reports | |
reports: $(Build.SourcesDirectory)/tests/TestResults/Coverage/coverage.cobertura.xml | |
- task: PublishCodeCoverageResults@1 | |
displayName: Publish Code Coverage | |
inputs: | |
codeCoverageTool: 'Cobertura' | |
summaryFileLocation: $(Build.SourcesDirectory)/tests/TestResults/Coverage/coverage.cobertura.xml | |
reportDirectory: $(Build.SourcesDirectory)/tests/TestResults/Coverage/Reports | |
- task: ArchiveFiles@2 | |
displayName: 'Archive Function Artifact' | |
inputs: | |
rootFolderOrFile: '$(Build.SourcesDirectory)/functions/bin/Debug/netcoreapp3.1' | |
includeRootFolder: false | |
archiveType: 'zip' | |
archiveFile: '$(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip' | |
replaceExistingArchive: true | |
- task: PublishBuildArtifacts@1 | |
displayName: 'Publish Function Artifact' | |
inputs: | |
PathtoPublish: '$(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip' | |
ArtifactName: 'drop' | |
publishLocation: 'Container' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Pipeline to build, test, and deploy packages with Maven | |
# Artifact Feed information must be replaced | |
# Triggers assume gitflow branching strategy | |
# Only snapshots are deployed to the Azure Artifacts repository | |
trigger: | |
- develop | |
- user-story/* | |
- release/* | |
variables: | |
- group: Maven Release Pipelines | |
pool: | |
vmImage: 'ubuntu-latest' | |
stages: | |
- stage: | |
displayName: Build snapshot | |
jobs: | |
- job: Feature | |
displayName: Validate feature branch | |
condition: eq(variables['build.sourceBranch'], 'refs/heads/user-story') | |
steps: | |
- task: MavenAuthenticate@0 | |
inputs: | |
artifactsFeeds: 'TCCC' | |
- task: Maven@3 | |
displayName: Build and deploy snapshot | |
condition: | |
inputs: | |
mavenPomFile: 'pom.xml' | |
mavenOptions: '-Xmx3072m' | |
javaHomeOption: 'JDKVersion' | |
jdkVersionOption: '1.8' | |
jdkArchitectureOption: 'x64' | |
publishJUnitResults: true | |
testResultsFiles: '**/surefire-reports/TEST-*.xml' | |
goals: 'test' | |
- job: Snapshot | |
displayName: Build develop branch and publish snapshot version | |
condition: eq(variables['build.sourceBranch'], 'refs/heads/develop') | |
steps: | |
- task: MavenAuthenticate@0 | |
inputs: | |
artifactsFeeds: 'TCCC' | |
- task: Maven@3 | |
displayName: Build and deploy snapshot | |
condition: | |
inputs: | |
mavenPomFile: 'pom.xml' | |
mavenOptions: '-Xmx3072m' | |
javaHomeOption: 'JDKVersion' | |
jdkVersionOption: '1.8' | |
jdkArchitectureOption: 'x64' | |
publishJUnitResults: true | |
testResultsFiles: '**/surefire-reports/TEST-*.xml' | |
goals: 'deploy' | |
- job: Release | |
displayName: Build master branch and publish release version | |
condition: startsWith(variables['build.sourceBranch'], 'refs/heads/release') | |
variables: | |
ADO_USER: $(USERNAME) | |
ADO_PASS: $(PASSWORD) | |
steps: | |
- task: MavenAuthenticate@0 | |
inputs: | |
artifactsFeeds: 'TCCC' | |
- task: Maven@3 | |
displayName: Build and package release | |
condition: | |
inputs: | |
mavenPomFile: 'pom.xml' | |
mavenOptions: '-Xmx3072m' | |
javaHomeOption: 'JDKVersion' | |
jdkVersionOption: '1.8' | |
jdkArchitectureOption: 'x64' | |
publishJUnitResults: true | |
testResultsFiles: '**/surefire-reports/TEST-*.xml' | |
goals: 'test' | |
- task: PublishBuildArtifacts@1 | |
displayName: Publish build artifact | |
inputs: | |
PathtoPublish: '$(Build.SourcesDirectory)/' | |
ArtifactName: 'drop' | |
publishLocation: 'Container' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment