Last week I published an article about the new capabilities of Azure DevOps pipelines (with YAML). As I promised we continue this topic on Today. Although the last week provided documentation contains the most important information, I feel I should show you how it works in the real life. Why? Because the documentation is not the best for that….as usual.

Scenario for today: Create a basic NodeJS project which is stored on GitHub repository. This NodeJS project is a simple script which will be executed by Azure DevOps pipeline via a YAML file.

After this “episiode” you are able to execute automatically any of your existing NodeJs script or solution in Azure DevOps pipeline. This means you will have a CICD-like solution from your existing NodeJS solution. It’s cool, isn’t it?

Additionally, I’ve decided to create a video guide for this article, which helps you to see the whole flow, step-by-step. You can find it below.

Step 1: Create a GitHub repository for your code

As usually the first step to create a private or public repository on GitHub. This is a basic steps and I assume you can do it. 🙂

Step 2: Write your basic code with YAML file

Next step after GitHub repository creation to clone the repository to the local computer. For this I use Visual Studio code.

Open your cloned repository and start to create the NodeJS solution.

Create the following 3 files:

package.json: This contains the project related information and the required package list for your solution.

startPilepine.js: This is our very basic existing NodeJS solution. Later on you can replace it to your existing solution.

pipeline.yaml: According to this file the Azure DevOps will build the pipeline. So this file contains the pipeline related information such as environment settings, pipeline steps, triggers.

Step 5: Create pipeline

Next steps to Select a repository from GitHub. If you are not connected from Azure DevOps to GitHub yet, you have to do it here. If you are connected from Azure DevOps to GitHub you can see the list of your repositories and you can choose the required one.

When you select the required repository you can see the Approve & Install Azure Pipelines window where you have to grant access to your repository to Install pipelines.

After this, you can start the configuration of pipeline. For this please choose the Existing Azure Pipelines YAML file options at the Configure your pipeline screen.

Then a sidebar appears on the right side of the screen (Select an existing YAML file) where you must select the YAML (files from the required branch) which contains the pipeline related information. Select the pipeline.yaml then click on Continue button.

Accordingly the pipeline has been created after some seconds. Here you can Run immediately it or just Save.

From this you have a Pipeline from a YAML file.

Step 6: Execute the pipeline

Great, we have a pipeline. To execute this pipeline we have now 2 (two) options: