A great way to improve the quality of your application is to automatically build it whenever you make changes. This enables you and your team to see if the application still works and fix errors quickly. You can easily set up a build pipeline withAzure Pipelines, which is part ofAzure DevOps.
In this post, we'll create an Azure Pipeline that builds and tests aNode.js application.
If you want to follow along, you'll need the following:
Create anew projectand click on it when you are done
(Azure DevOps project)
In the "Welcome to the project!" pane, click onPipelinesto start creating a new Azure Pipeline. This will start a wizard
First, we need to indicate where our code is. It is in GitHub, so selectGitHub
(Code choices in the Azure Pipelines wizard)
Next, you'll see a list of repositories in your GitHub account. Select theforked repositorythat contains thesample Node.jsapplication a. You might have to authorize Azure DevOps to use the GitHub repository. If so, clickApprove & Install
In the next step, selectNode.jsto configure the pipeline for Node.js
(Configuration choices in the Azure Pipelines wizard)
The next screen shows you theYAML codethat defined the pipeline. You can learn more about YAMLhere. This code determines that node.js will be used and that the pipeline will perform a build. This code will only build the code and not execute any unit tests. Let's change that:
a. In thescriptsection of the YAML code, add the following to enable the pipeline to run the unit tests in the code:
b.Below the scripts section, add the following code to publish the test results to the build results:
Now clickSave and runto save the pipeline and start it. The pipeline will now start building and testing the code. When it is done, you'll see the results like in the image below:
(Results of the Azure Pipeline)
The build was successful! In the screen of the build results, you can click theTeststab to see the results of the Unit Tests
In the test result screen, you can see the Unit Tests that ran (which is only one test in this case), and what the result of the run was
(Test results of the Azure Pipeline)
That's it. We have set up a pipeline that automatically builds and tests the application when changes are made to it. From here, you can set up more pipelines, like a release pipeline, that takes the build result and deploys it to a server. You can learn more about thathere.
Setting up a Continuous Integration (CI) process, which builds your code automatically, is one of the simplest ways to increase the quality of your applications. It is very easy to set up a CI pipeline withAzure Pipelines, regardless of the programming language that you use or where your code is. To learn more, create a trial account today and go and check it out