Example Azure DevOps Pipeline for Angular

5/17/2023
Back to List

This example Azure pipeline for Angular performs the following steps:

  1. It triggers the pipeline when changes are pushed to the main branch, specifically within the 'src' directory.
  2. It specifies the agent pool to use, in this case, an Ubuntu-based agent.
  3. It installs Node.js using the NodeTool task.
  4. It installs the npm dependencies required for the Angular project.
  5. It builds the Angular app in production mode using the npm run build command.
  6. It copies the build output files from the dist directory to a staging directory.
  7. It publishes the build artifacts, creating a drop containing the build output.
trigger:
branches:
include:
- main # Build when changes are pushed to the main branch
paths:
include:
- 'src/**' # Only trigger the build if changes are made within the 'src' directory

pool:
vmImage: 'ubuntu-latest' # Choose the appropriate agent image for your project

steps:
- task: NodeTool@0
inputs:
versionSpec: '14.x' # Use the appropriate Node.js version
displayName: 'Install Node.js'

- script: npm install
displayName: 'Install npm dependencies'

- script: npm run build -- --prod
displayName: 'Build Angular app'

- task: CopyFiles@2
inputs:
SourceFolder: '$(Build.SourcesDirectory)/dist' # Specify the build output directory
Contents: '**' # Copy all files
TargetFolder: '$(Build.ArtifactStagingDirectory)/dist'
displayName: 'Copy build output'

- task: PublishBuildArtifacts@1
inputs:
pathtoPublish: '$(Build.ArtifactStagingDirectory)/dist'
artifactName: 'drop'
displayName: 'Publish build artifacts'

SuperChad
Gravatar About Sean Nelson
I like codes and stuff.

0 comments