Automating Node.js Builds with Azure DevOps Pipelines

Challenge: Part 1 Continuous integration
Set up a new repository and CI pipeline using any code version provider The CI steps should be created. The pipeline should run the following steps:
Install dependencies npm install
Linter (ESLint) npm run lint
Formatter (Prettier) npm run prettier
Test (Jest) CI=true npm run test
Build npm run build
The pipeline should be successful. Please provide some pull requests to show pass or fail status in the CI pipeline.
Prerequisites
- Azure Devops Account
Step 1: Create and clone the Repository
Create New Project:
Once inside your organization's Azure DevOps dashboard, click on the "New Project" button, usually at the top right or in the center of the screen.
Configure Project Details:
Project Name: Enter "DevOps Challenge" as the project name.
Go to Repos -> Import Repository -> Clone URL: https://github.com/joaochiroli/Devops-Challenge
Step 2: Create and configure azure-pipelines.yml
Create file
azure-pipelines.ymltrigger: - main pr: branches: include: - main stages: - stage: BuildAndTest displayName: Build and Test Job pool: vmImage: 'ubuntu-latest' jobs: - job: Build displayName: 'Build and Test Job' steps: - checkout: self path: 'src' displayName: 'Checkout code' - task: UseNode@1 inputs: version: '15.x' displayName: 'Install Node.js' - script: npm install workingDirectory: $(Build.SourcesDirectory)/assessment-cc-sre-kubernetes-sr-01/codebase/rdicidr-0.1.0 displayName: 'Install dependencies' - script: npm run lint workingDirectory: $(Build.SourcesDirectory)/assessment-cc-sre-kubernetes-sr-01/codebase/rdicidr-0.1.0 displayName: 'Linter (ESLint)' - script: npm install --save-dev prettier workingDirectory: $(Build.SourcesDirectory)/assessment-cc-sre-kubernetes-sr-01/codebase/rdicidr-0.1.0 displayName: 'Install Formatter (Prettier)' - script: npm run prettier -- --write workingDirectory: $(Build.SourcesDirectory)/assessment-cc-sre-kubernetes-sr-01/codebase/rdicidr-0.1.0 displayName: 'Format Code (Prettier)' - script: CI=true npm run test workingDirectory: $(Build.SourcesDirectory)/assessment-cc-sre-kubernetes-sr-01/codebase/rdicidr-0.1.0 displayName: 'Test (Jest)' - script: npm run build workingDirectory: $(Build.SourcesDirectory)/assessment-cc-sre-kubernetes-sr-01/codebase/rdicidr-0.1.0 displayName: 'Run Build'Commit and Save
Explanations:
I created trigger main and pr to start my pipeline. I use 1 stage to Build my application.
Task: UseNode@1 → Define the Node.js version
The other tasks do what the above steps ask, and the key to this build is to run it in the correct repository.
Step 3: Results





