In this hands-on lab, you will be taking an existing Node.js app and running it through a DevOps pipeline in Azure Pipelines. Also within Azure Pipelines, you will modify the deployment YAML in order to specify the version of Node.js and publish the build results to Azure Test Plans.
Successfully complete this lab by achieving the following learning objectives:
- Create a New Azure DevOps Organization
- Log in to the Azure portal, click on All Services, and select Azure DevOps.
- Click on the My Azure DevOps Organizations link (this will open a new tab).
- Once the fields have auto-populated with the name, email, and location, click on the Continue button.
- Under Get Started with Azure DevOps click the Create new organization button.
- If prompted to agree to the terms of service, click the Continue button.
- Choose a name for your new DevOps organization (the default will suffice).
- Choose the location Central US for the region to host your projects in and click Create.
- In the Project Name field, enter "nodejs" and click the Create Project button.
- Create a Repository for the Application in an Azure Repo
- From within your Azure DevOps organization, click on Repos in the menu on the left-hand side of the screen.
- On the page titled "nodejs is empty. Add some code!", click the grey Import button.
- Click on Import.
- Create a New Pipeline and Run the First Build
- From within your Azure DevOps organization, click on Pipelines from the menu on the left-hand side of the screen.
- Click on the New pipeline button.
- On the Connect step, under Where is your code, select Azure Repos Git.
- On the Select step, under Select a repository, select nodejs.
- On the Configure step, under Configure your pipeline, select Node.js.
- On the Review step, to the right of Review your pipeline YAML, click the Save and run button.
- On the popup, under Save and Run, enter a commit message (the default message will suffice), select Commit directly to the master branch and click the Save and run button again.
- Verify that the first build was successful by watching the output.
- Edit the Build to Include a Specific Version of Node.js and Publish the Test Results
- From within your Azure DevOps organization, click on Repos from the menu on the left-hand side of the screen.
- Select the file named
azure-pipelines.ymland click on Edit.
- Under the task NodeTool@0 change the versionSpec from 10.x to 10.14.
- Click on Commit, enter a commit message (the default will suffice) and click the Commit button.
- In the code repository, verify there’s a file named
- Select the
package.jsonfile from within the code repository.
- Verify that
mocha-junit-reporteris installed as a dependency.
- Click on Pipelines from the left-hand menu bar.
- Click nodejs.
- In the upper-right corner of the screen, select the grey Edit button.
- Place the cursor at the bottom of the
azure-pipelines.ymlfile, under the
- On the right-hand side of the screen under Tasks, use the search bar to search for the task "Publish Test Results".
- Select Publish Test Results and under Test Result Format, choose JUnit and under Test results files, type "**/TEST-RESULTS.xml".
- Leave everything else as default and click the Add button at the bottom of the screen.
- In the upper-right corner of the screen, click the Save button.
- Enter a commit message (the default will suffice), and choose Commit directly to the master branch. Then click the Save button.
- In the breadcrumb link navigation at the top, click Builds.
- Select the most recent build (at the top) from the history.
- Verify that the build was successful by watching the output on the screen.
- Click on Test Plans from the left menu bar.
- Under Test Plans, click on Runs.
- Double-click on the most recent test run and view the outcome.