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
Newsletter
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Using Azure DevOps Pipeline With Gopaddle for No-Code Kubernetes Deployments
  • Release Pipeline Using Azure DevOps
  • Mule 4 Continuous Integration Using Azure DevOps
  • Optimizing Azure DevOps Pipelines With AI and Continuous Integration

Trending

  • 7 Swift Features That Will Let You Delete Code Tomorrow
  • Avoiding AI Debt as a Team
  • Save To Bookmarks/Favorites
  • Catching Query Regressions Before Your Users Do

Draft This article hasn't been published, so readers can't see it.

In moderation This article is waiting for review, so readers can't see it yet.

Deleted This article has been deleted, so readers can't see it.

  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
·
Updated Apr. 11, 24 · Tutorial
Post on X (opens in a new tab) Share on LinkedIn (opens in a new tab)
48.0K Views

Join the DZone community Save articles, join the discussion, and download Refcards and Trend Reports with a free account.

Join for free Already a member? Log in

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
  • Optimizing Azure DevOps Pipelines With AI and Continuous Integration

Partner Resources

×

Comments

Loading comments

The comments didn't load

Please try again in a moment.

Likes

Loading

The next likes didn't load. Please try again.

The likes didn't load

Please try again in a moment.

See who liked this

Log in or join DZone for free to see who liked this article.

Log in Join for free
  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

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 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook