here."> here."> here."> Build and Deploy a Node.js Application into Azure Web Apps Using Azure DevOps (CI/CD)

Build and Deploy a Node.js Application into Azure Web Apps Using Azure DevOps (CI/CD)

Build and Deploy a Node.js Application into Azure Web Apps Using Azure DevOps (CI/CD)
This post is as an introduction to Azure DevOps. If you're new to this topic, check out a helpful DZone article here.

In this tutorial, we look at how to get a Node.js app up and running and then deploy it to an instance of Azure DevOps.

This post is as an introduction to Azure DevOps. If you're new to this topic, check out a helpful DZone article here.

We'll use an azure-pipelines.yml file at the root of the repository. Get this file to build the Node.js application using CI (Continuous Integration) Build.

Follow the instructions in Create your build pipeline to create a build pipeline for your node application.

Steps:

pool:
  name: Hosted Ubuntu 1604
  demands: npm
steps:
- task: [email protected]
  displayName: 'WhiteSource '
  inputs:
    cwd: 'cctitan-ui-code'
    extensions: '.json .js .ts .css .html'
    productName: UIcode
    WhiteSourceService: 'cc-titan'
  enabled: false
- task: [email protected]
  displayName: 'Use Node 8.x'
  inputs:
    versionSpec: 8.x
task: [email protected]
  displayName: 'npm install'
  inputs:
    workingDir: 'cctitan-ui-code'
- task: [email protected]
  displayName: 'install angular [email protected]'
  inputs:
    command: custom
    workingDir: 'cctitan-ui-code'
    verbose: false
    customCommand: 'install -g @angular/[email protected] '
- bash: |
   ls /home/vsts/work/1/s
   cd cctitan-ui-code 
   ls
   ng --version
   ls
   ng build
   ls
- task: whitesource.ws-bolt.bolt.wss.WhiteSource [email protected]
  displayName: 'WhiteSource Bolt'
  inputs:
    cwd: 'cctitan-ui-code'
- bash: |
 cd CCtest
 npm install karma karma-jasmine karma-chrome-launcher karma-jasmine-html-reporter karma-coverage-istanbul-reporter
 npm install karma-coverage --save-dev
 npm install karma karma-coverage
 ng test --watch=false --code-coverage
displayName: 'CodeCOverage tests'
- task: [email protected]
  displayName: 'Archive cctitan-ui-code/dist'
  inputs:
    rootFolderOrFile: 'cctitan-ui-code/dist'
    includeRootFolder: false
- task: [email protected]
  displayName: 'Publish Artifact: drop'

Publish the test results to Azure pipelines or TFS when tests are executed to provide complete test reports and analytics. Use the test runner that supports the required test results format. Some specific result formats include JUnit, NUnit, and Visual Studio Test (TRX). This task will generate the JUnit XML formats, and Azure DevOps Build will use this XML file in its build task to grab the test results and publish to the dashboard summary of the build.

steps:
- task: [email protected]
  displayName: 'Publish Test Results **/test-results*.xml **/e2e-results-junit*.xml '
  inputs:
    testResultsFiles: |
     **/test-results*.xml
     **/e2e-results-junit*.xml
    mergeTestResults: true
  continueOnError: true
  condition: succeededOrFailed()


steps:
- task: [email protected]
  displayName: 'Deploy Azure App Service'
  inputs:
    azureSubscription: '$(Parameters.ConnectedServiceName)'
    appType: '$(Parameters.WebAppKind)'
    WebAppName: '$(Parameters.WebAppName)'
    TakeAppOfflineFlag: true


Originally published by  Sudheer Mareddy at dzone.com

----------------------------------------------------------------------------------------------------------------------------

Thanks for reading :heart: If you liked this post, share it with all of your programming buddies! Follow me on Facebook | Twitter

Learn More

☞ The Complete Node.js Developer Course (3rd Edition)

☞ Angular & NodeJS - The MEAN Stack Guide

☞ NodeJS - The Complete Guide (incl. MVC, REST APIs, GraphQL)

☞ Node.js: The Complete Guide to Build RESTful APIs (2018)

☞ Learn and Understand NodeJS

☞ MERN Stack Front To Back: Full Stack React, Redux & Node.js

☞ Learn Node.js - Node.js API Development for Beginners

☞ Moving from NodeJS to Go

☞ How to Perform Web-Scraping using Node.js

☞ Node.js, ExpressJs, MongoDB and Vue.js (MEVN Stack) Application Tutorial

☞ Top 10 Node.js Frameworks