Azure DevOps release pipeline test and deploy screenshot

Continuous integration(CI) and continuous delivery(CD) pipelines have become the norm in software engineering. In the corporate world, a CI/CD pipeline is especially useful to ensure your entire development team is following the best quality guidelines and drastically shorten the deployment cycle to satisfy your customers. Thus why all Cloud providers are now providing their CI/CD pipeline platform. In this tutorial, we will focus on how to use the Azure DevOps platform on a Java project.

Create a new Java spring web application on Azure App Service:

  • Log on portal.azure.com
  • Navigate to the App Services
  • Add a new Web App
  • Select your existing subscription level
  • Remember its name

Create a new Java DevOps project on Azure DevOps:

  • Log on dev.azure.com with the same Azure account
  • Create a “new project” and enter the needed information
Azure DevOps project creation screenshot
  • Navigate to the project settings and activate all the services
Azure Devops services selection screenshot
Azure DevOps services selection screenshot
Azure Devops pipeline clone repository screenshot
Azure DevOps pipeline clone repository screenshot
  • Your Repository code is available as below
Azure Devops repos files screenshots
Azure DevOps repository files screenshots

Create a build pipeline with Maven on your Azure DevOps Repository:

The objective here is to build your Java application everytime there is a commit or a merge on your master branch.

  • Navigate to your Repository > Files > Set up build > New Pipeline > Configure > Maven Package
Azure Devops configure your pipeline screenshot
Azure DevOps configure your pipeline screenshot
  • Azure DevOps will generate its own azure-pipelines.yml as follow:

  • To test your build pipeline, simply modify a file in your repository master branch.
Azure Devops build Maven pipeline screenshot
Azure DevOps build Maven pipeline screenshot

Create a publish pipeline on your Azure DevOps Pipeline tool:

Now that we have a build pipeline to continuously test and build our codebase we can create a release pipeline to continuously deploy our modification to a development server.

  • Navigate to Repository > Releases > New Release Pipeline
  • Select a Template > Empty Job
  • Add a new stage to your empty build pipeline
Azure Devops release pipeline add stage screenshot
Azure DevOps release pipeline add stage screenshot
  • On this new release, pipeline navigate to Artifact > Add > Source > java_pipeline_demo_build (or any other name you gave it)
Azure Devops add an artifact to your pipeline screenshot
Azure DevOps add an artifact to your pipeline screenshot

Now we need to specify on wich Azure App Service to deploy our Java artifact:

  • On this new release, pipeline navigate to Tasks > Dev > Agent Job > + > Azure App Service Deploy
    • Connection Type: Azure Ressource Manager
    • Azure Subscription: YOUR_SUBSCRIPTION
    • App Service type: Web app on Linux
    • App Service Name: THE_NAME_YOUR_PROVIDED_ON_STEP_1
    • Package or folder: Select the .war
    • Runtime stack: Java SE (JAVA|8-jre8)
Azure DevOps release pipeline deploy screenshot
Azure DevOps release pipeline deploy screenshot
  • On this new release, pipeline navigate to Pipeline > Artifact > Continuous deployment trigger > Enable
  • Name the pipeline
  • Save
  • Create Release
Azure DevOps release pipeline test and deploy screenshot
Azure DevOps release pipeline to test and deploy screenshot

That’s it. From now on each commit on your Azure DevOps repository will trigger a build pipeline. The Java Artifact built will trigger a release pipeline. This release pipeline will add this Java Artifact to your Azure App Service server seamlessly deploying your modifications.

Was this post helpful?

Share: