GitHub integration with Azure Pipelines
GitHub?hosts over 100 million repositories containing applications of all shapes and sizes. But GitHub is just a start—those applications still need to get built, released, and managed to reach their full potential.
Azure Pipelines?that enables you to continuously build, test, and deploy to any platform or cloud. It has cloud-hosted agents for Linux, macOS, and Windows; powerful workflows with native container support; and flexible deployments to Kubernetes, VMs, and serverless environments.
Prerequisites
These items are required for this lab.
Exercise 1: Setting up automated CI/CD pipelines with Azure Pipelines
In this exercise, we will help Contoso Air revamp a critical component of their DevOps scenario. Like all airlines, they rely on their web site to generate and manage business opportunities. However, the current processes they have in place to move a change from their source code to their production systems is time-consuming and open to human error. They use GitHub to manage their source code and want to host their production site on Azure, so it will be our job to automate everything in the middle.
This will involve setting up a pipeline so that commits to the GitHub repo invoke a continuous integration build in Azure DevOps. Once that build is complete, it will invoke a continuous delivery deployment to push the bits out to Azure, creating the required resources, if necessary. The first thing we need to do is to connect GitHub with Azure DevOps, which we can do via the?Azure Pipelines?extension in the GitHub Marketplace.
Task 1: Installing Azure Pipelines from GitHub Marketplace
Azure Pipelines?is available in GitHub Marketplace which makes it even easier for teams to configure a CI/CD pipeline for any application using your preferred language and framework as part of your GitHub workflow in just a few simple steps
3.Search for “pipelines” and click?Azure Pipelines.
Scroll to the bottom and click?Install it for free. If you previously installed Azure Pipelines.
2: Configuring a Continuous Integration Pipeline
Azure Pipelines has been installed and configured, we can start building the pipelines but we will need to select a project where the pipeline will be saved. You may select an existing or create a new Azure DevOps project to hold and run the pipelines we need for continuous integration and continuous delivery.
领英推荐
2.Take node.js for pipeline schema
pool
vmImage: 'ubuntu-16.04'
trigger:
- master
steps:
- task: CopyFiles@2
displayName: 'Copy Files to: $(build.artifactstagingdirectory)/Templates'
inputs:
SourceFolder: deployment
Contents: '*.json'
TargetFolder: '$(build.artifactstagingdirectory)/Templates'
- task: Npm@1
displayName: 'npm custom'
inputs:
command: custom
verbose: false
customCommand: 'install --production'
- task: ArchiveFiles@2
displayName: 'Archive $(Build.SourcesDirectory)'
inputs:
rootFolderOrFile: '$(Build.SourcesDirectory)'
includeRootFolder: false
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: drop':
pool
vmImage: ubuntu-16.04
trigger:
- master
steps:
- task: Npm@1
inputs:
command: 'custom'
customcommand: 'install --production'
- script: |
npm install
npm test
displayName: 'Run unit tests'
continueOnError: true
- task: PublishTestResults@2
displayName: 'Publish Test Results'
condition: succeededOrFailed()
inputs:
testResultsFiles: $(System.DefaultWorkingDirectory)/test-report.xml
- task: PublishCodeCoverageResults@1
displayName: 'Publish Code Coverage'
condition: 'in(variables[''Agent.JobStatus''], ''Succeeded'')'
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: '$(System.DefaultWorkingDirectory)/coverage/*coverage.xml'
reportDirectory: $(System.DefaultWorkingDirectory)/coverage
- task: ArchiveFiles@2
displayName: 'Archive sources'
inputs:
rootFolderOrFile: $(Build.SourcesDirectory)
includeRootFolder: false
- task: CopyFiles@2
displayName: 'Copy ARM templates'
inputs:
SourceFolder: deployment
Contents: '*.json'
TargetFolder: $(build.artifactstagingdirectory)/Templates
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: drop':
Author: Anil Samayam -