Creating a Maven CICD Pipeline for Java web application is as easy as baking a cookie

puzzle, keep, hands-6640058.jpg

In this guided hand on CICD project, you will be creating a Java web application through Azure DevOps

Section1 – Steps to create a Maven Pipeline for Java based application

Login to DevOps portal:  dev.azure.com and enter login details

Image : Sign into Azure DevOps Portal
  1. Create + sign to start creating a “new project”  on the portal
Image : Click to create a new project
  1. Fill in the details as needed for your new project
Create Project in Azure Devops
  1. An overview inside DevOps after the project is successfully created
Overview after the project is created
  1. Click on Repos and upload your code or import it. If you have a code on existing GIT repo, you can choose clone option for the code to be available
Upload code files in DevOps repo
  1. Navigate to code location and verify that the code is successfully uploaded and available
Source code in the repo

Until here we have our code-files ready in our repo to proceed further with creating a build pipeline. In the next section, we’ll look into how to create a build pipeline using a classic editor.

Section 2 –    Create a build pipeline in Azure DevOps

What is Azure pipeline ?

Azure Pipeline is a cloud service that we can use to build and test our code project automatically.

  1. Click on select classic editor
Create pipeline with classic editor
  1. Now you will be prompted to choose the source location of your code. I have chosen Azure repos as my code exist there. You can choose your source accordingly
Select a source of your code
  1. In the Select a template screen, select Empty job. A job is a collection of steps that are runs in a sequence for the defined environment
Create pipeline with an empty job
Section 3 – Add tasks to the pipeline

We will now add new tasks to perform specific jobs and configure to run in a sequence

  1. Click + sign next to Agent job 1
Add task
  1. Select task and continue to add them as per the sequence defined in the image
Task sequence order
  1. Configure respective tasks for your build definition as described in the below images
Configure Maven task
Configure file copy from source to target
Copy ARM template
  1. Configure path to publish and click save and queue
Publish artifacts
  1. Click run
Build pipeline run
  1. After clicking run, the job is queued and will be executed one the agent gets available
Job status

  1. Images showing running of the job and successful completion
List of executed task and related summary
  1. Click on summary to verify the job status – as success. Notice that it reflects 1 published, it is the artefact which will be used during release pipeline
Job status
Section 4 – Create Release Pipeline
  1. Navigate to Pipeline on the left side menu and select Releases >>> click New Release Pipeline
  1. Select a Template > Empty Job
  1. Add a new stage to your empty build pipeline
  1. Enter the text as desired
  1. Click on pipeline and select “Add an Artifact”, select the values as appropriate from the drop down on the right
Add an artifact
  1. Click Add to select Artifact
  1. Click on the + sign and add the tasks as shown in the picture

Tasks to add: ARM template Deployment and Deploy Azure App Service

Add task
  1. Provide details as requested
    • Subscription : Your subscription
    • App type : Web app on Linux
Job overview
  1. ARM connection manager details from the drop down
Task overview- ARM deployment
  1. Click on 3 dots and navigate to Drop artefact location
  1. Choose the template file. Click of to populate the path
  1. Web app deployment details:  Copy and paste the details in the override template parameters section. You can update the same per your requirement after selecting 3 dots as well

-webAppName mydemo-javaapp -hostingPlanName mydemo-javaapp-plan -appInsightsLocation “West Europe” -sku “P1v2 Premium”

Template parameters
ARM template deployment configuration
  1. Select task “Deploy Azure App Service”, enter the details as appropriate
  1. Ensure WAR file is selected
Select war file
  1. Save your release. Click OK
Save the release
  1. Create Release and watch on screen progress for deployment
Create release
  1. Watch on screen for the process and process to finish
  1. Navigate to Azure portal and verify that the relevant services are provisioned
  1. In Azure Portal, click the URL and VOILA!! You have done it

Thank  you for reading. I hope you’ll find the post useful.

Leave a Comment

Your email address will not be published. Required fields are marked *