DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Last call! Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • Using Azure DevOps Pipeline With Gopaddle for No-Code Kubernetes Deployments
  • Release Pipeline Using Azure DevOps
  • Mule 4 Continuous Integration Using Azure DevOps
  • Deploying MuleSoft Using Azure DevOps

Trending

  • From Zero to Production: Best Practices for Scaling LLMs in the Enterprise
  • Performing and Managing Incremental Backups Using pg_basebackup in PostgreSQL 17
  • Intro to RAG: Foundations of Retrieval Augmented Generation, Part 1
  • Building Enterprise-Ready Landing Zones: Beyond the Initial Setup
  1. DZone
  2. Testing, Deployment, and Maintenance
  3. DevOps and CI/CD
  4. Building CI/CD Pipelines for Java Using Azure DevOps

Building CI/CD Pipelines for Java Using Azure DevOps

Visual Studio Team Services has become Azure DevOps. Java devs can learn how to build a release automation pipeline for their web applications.

By 
Ruth Yakubu user avatar
Ruth Yakubu
·
Updated Apr. 11, 24 · Tutorial
Likes (5)
Comment
Save
Tweet
Share
46.3K Views

Join the DZone community and get the full member experience.

Join For Free

Let’s face it, most Java developers cringe and run when they see the term “Visual Studio” with the misconception that the tool will be for .NET users only.  I have to confess; I was one of those guilty Java developers until I discovered that it is actually a powerful solution for any language or platform to utilize during project release cycles.

The Azure DevOps service offers several features for such as adding team members, Kanban boards, Repo options, Build/Release Pipelines, Test Plans, Build Artifacts (e.g. Maven) and much more. It also integrates with your favorite tools like Eclipse, IntelliJ, Jenkins or Chef.  For microservices, Java developers will be happy to know that it supports container build services like Docker, Kubernetes, Cloud Foundry etc.

This tutorial will demo the use of Azure DevOps to set up a release automation to build and deploy a Java web application.

Prerequisites

  • Register or log into your Azure DevOps account
  • Copy and save the Git URL for the sample Java code from GitHub
  • Create an Azure Web App (Note: choose the following options for this Java web app. OS = Linux, Runtime Stack = JRE 8)

How to Build CI/CD Pipelines for Java Using Azure DevOps

1. Create a Project and Git Repository

  1. On the Azure DevOps projects page, click "New Project" then enter your project name. 
  2. Select "Git" in the "Version Control" drop-down, then click the "Create" button to continue
  3. Click on the "import" button below the "or import a repository" to paste in the Git URL for the sample Java code above.  Then click on "Import" to continue

Image title

2. Create a Build Definition for Maven

The build definition in Azure DevOps automatically executes all the tasks in the build each time there’s a commit in the Java source application. In this example, Azure DevOps will use Maven to build a Java Spring Boot project.

  1. Click on the Build and Release tab on top of your Azure DevOps project page. Then select the "Builds" link
  2. Click on the New Pipeline button, and then "Continue" to start defining your build tasks
  3. Select "Maven"from the list of templates, then click on the "Apply" button to build your Java project

    Image title

  4. Use the drop-down menu for the Agent pool field to select Hosted Linux Preview option.  This informs Azure DevOps which build server to use. You can also use your private customized build server
  5. To configure your build for continuous integration, select the Triggers tab and check the Enable continuous integrationcheckbox.

    Image title

  6. Use the Save & queue drop-down menu to select the Save & queue option.
  7. In the pop-up window, verify that "Hosted Linux Preview" is select as the Agent pool field.  Then click on the queue button to build the java application.
  8. Verify that the build tasks completed successfully by clicking on the generated build number.

Image title


3. Create a Release Definition the Java Web App

The release pipeline in Azure DevOps automatically triggers the deployment of build artifacts to any target environment like Azure as soon as the Build process completes successfully. The release pipeline can be created for dev, test, staging or production environments.

  1. Click on the Build and release tab on top of your project page.  Then select the “Releases” link.
  2. Click on the New pipeline button.  On top of the list of templates, then click on the “Empty job” link
  3. Enter a "Stage name" (e.g Dev, Test, Staging or Production).  Then click on the “X” button to close the pop-up window
  4. Click on the "+ Add" button in the Artifacts section. This will link artifacts from the build definition (e.g. Maven build) to this release definition.  Image title

  5. Use the drop-down menu for the "Source (build pipeline)" to select your build definition. Then click the "Add" button to continue.
  6. Click on the "Tasks" tab on the pipeline.  Then, select your stage name.
  7. Click on the "+" link on the Agent Job section to add a deployment task.
  8. Select  the "Azure App Service Deploy" task under the list of tasks, then click on the "Add" button
  9. On the "Azure App Service Deploy" page, set the version to "4.* (preview)" in the drop-down menu
  10. Use the "Azure subscription" drop-down menu to select your Azure subscription ID.
  11. Select "Web App on Linux" from the "App Service type" drop-down menu
  12. Select the name of the Azure Web App instance you created above in the "App service name" drop-down menu.
  13. For the "Package or folder" field, navigate to the project generated .jar file Image title

  14. Select the "JRE 8" in the "Runtime Stack" drop-down.  Note:  click the refresh button next to the field if you don’t see the JRE 8 in the list.
  15. Click on the "Agent job" link on the left navigation bar.  Select "Hosted Linux Preview" in the Agent pool drop-down menu
  16. To enable continuous deployment, click the "Pipelines" tab
  17. In the Artifacts section, click on the lightning icon.  Then set the "Continuous deployment trigger" to Enabled. Click on the "Save" button, then the "OK" button.Image title

  18. Click on the "+ Release" drop-down menu, then select "Create a release."
  19. In the pop-up window, click on the "Create" button.
  20. Click on the generated “release number” to check the status of your deployment.

4. Test Your Deployed Java Web Application

  1. Open a web browser and paste your web app URL:
    https://{your-app-service-name}.azurewebsites.net
  2. The web page should display the Spring Music Albums:

Image title

Summary

It's nice to see Microsoft making strides to enable all developers by taking simple steps like naming changes that are more attractive and embrace many developer communities. Azure DevOps provides developers and teams with a robust solution to collaborate and automatically generate CI/CD pipelines to deliver applications faster.

Continuous Integration/Deployment azure Java (programming language) DevOps Pipeline (software)

Opinions expressed by DZone contributors are their own.

Related

  • Using Azure DevOps Pipeline With Gopaddle for No-Code Kubernetes Deployments
  • Release Pipeline Using Azure DevOps
  • Mule 4 Continuous Integration Using Azure DevOps
  • Deploying MuleSoft Using Azure DevOps

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!