Azure DevOps CI-CD Pipeline Tutorial – CD Part

This is the second part of the Create CI-CD project which mainly comprises the Continuous Delivery part of the pipeline. Please check Part-1 to configure the Continuous Integration part of the project. Learn more about CI-CD here.

We are going to deploy the artifact (war file) created in the Build Pipeline to an ec2 instance of AWS or you can other Virtual Machines as well. For the purpose of the demo, we are only going to deploy artifacts in a directory named “tomcat”.


Step 1. Creating a Release Pipeline

Go to the Releases in Pipelines on the left side of the Azure DevOps.

Click on the New Pipeline.

✔ Select a template: there are multiple deployment options for different platforms but we are going to select the Empty job as it is easy to configure the deployment pipeline for a single VM.


create release pipeline


In the next step, it will ask for the name of the stage. Provide a suitable name and then click on the cross sign at the right.

Similarly, you can more stages which represent other environments such as QA or Production.

You will see this next.


release pipeline


Step 2. Adding Artifact in Release Pipeline

Here, we will add the artifact that was created in Build Pipeline.

✔ Click on the Add Button in the Artifacts box.

Source type: Select the resource artifact source type. Choose the Build, from all the options.

Project: Select the correct project.

Source: Select the Build Pipeline name.

Default Version: Keep the value “Latest”.

Source alias: This is a unique identifier for the artifact in the release pipeline.

✔ Click on Add.


add artifact


Step 2. Setting up the Release Pipeline

✔ Give an appropriate name to the pipeline at the top.

✔ Now click on the link (1 Job, 0 tasks) below the name of the stage (in this case staging).

✔ Release Pipeline also has the Agent Job section which has the Agent pool and Agent Specification configuration.

✔ Click on the plus (+) icon in the Agent Job section and search for SSH.

✔ Next, add Copy files over SSH task from the search results in the pipeline.


add copy over ssh task


Step 3. Configuring the Remote Server for Copy files over SSH task.

To use Copy files over SSH task we need to configure the remote server/VM on which the artifact will be going to deploy. This type of configuration is called service connection in Azure DevOps.

✔ Click on the Manage link in the Copy files over SSH task beside SSH service connection.


add ssh server connection


✔ On the new browser tab, click on Create service connection.

✔ Look for SSH in options and click Next.

✔ Fill in all the required details:

    ✔ Host name: Enter the hostname or public IP address of the server/VM.

    ✔ Port Number: It will have the SSH port number of your server. (Default is 22)

    ✔ Private Key: Paste the private or upload the key here.

    ✔ Authentication:

        ✔ Username: Username for connecting the server.

        ✔ Password/Passphrase: Enter Password/Passphrase if available.

    ✔ Details:

        ✔ Service connection name: Give a suitable name.

        ✔ Description: Give a description.


ssh connection


Step 4. Configure Release Pipeline task.

Configure the Copy files over SSH task:

Display Name: Name of the task.

SSH service connection: Choose the Service connection configured in Step 3.

Source folder: Browse the war file and select the folder that has the war file (target folder) by clicking on the 3 dots at the right.

Contents: Keep the value as default. The two-asterisk sign (**) means everything in the select folder.

Target Folder: Provide the location where you want to deploy the artifact. i.e /home/ubuntu/tomcat                 

✔ Click on the Save button.


configure release pipeline


Step 5. Create the Release

Click on the Create release.

✔ Click on Create button on the next page and the release build will get started.

✔ To check the progress of the Release pipeline, click on the Release link that appeared on top.


release link


✔ To check the output, click on the staging box, and then it will open the console output of the different tasks of Release Pipeline.

✔ The Release Pipeline is successfully finished. With this, the artifact that is the war file is deployed to the staging server.


release logs


✔ We can check that by looking at the location we have configured in Release Pipeline.


deployed on server


Step 6. Enable Continuous Deployment

✔ Go back to the Pipeline tab of the Release pipeline.

✔ Click on the lightning icon on the artifact.

✔ Enable the Continuous deployment trigger.

✔ Save the configuration.


enabling CD


Now you can check the CI-CD working by making any change and pushing into the Azure Repos.



We have learned how to create a complete CI-CD project in Azure DevOps using Azure Repos and Azure Pipeline.