11Oct

DevOps with Visual Studio Team Services for Java

Java DevOps is simply applying DevOps practices and philosophies to Java app development. That means that compartmentalized teams are no longer needed when creating Java applications.

Benefits of Java DevOps

  1. DevOps take a people-first approach. Apart from bringing together your development, operations and other teams, DevOps require team members to understand the perspective of other members of the team. That may mean a developer is sharing his or her concerns with the team and a SysOp doing the same. This kind of understanding can enable team members to help each other, such as a developer building facilities and tools that another team member needs. As such, collaboration is not only encouraged by necessity. But even as you bring teams together, it also puts focus on accountability and ownership.
  2. Java DevOps cuts the time to develop a Java application. This will help you deliver the right Java applications to end users faster, and even become more efficient as time wears on. You can also adapt faster to every changing market conditions and demands.
  3. Better application quality. DevOps almost always require a shift to continuous integration, which means that every step of the application’s development is tested and monitored. Each change is also tested. It is because of this that Java DevOps can ensure that your Java applications have a positive experience for your users. Plus, DevOps can Increase security, rather than hinder it.
  4. You don’t get overwhelmed. You can manage and operate your applications, processes, and infrastructure at scale.

Before working on below Exercise you must have Azure account if you don’t have account, create one now.

Simply click the link to deploy to azure and all resources will be deployed to resource group. You can delete the resource group in order to remove all the created resources at any time.

  • Creating a VSTS account and Team Project
  1. You will need a Visual Studio Team Services (VSTS) account - if you do not have one, you can create one now.
  2. create a new project- link to create project.
  • Importing MySHuttle2 code from GitHub into VSTS.

 In this task, you will import code from a GitHub repo into VSTS

  1. Enter the following url:https://github.com/nwcadence/MyShuttle2.git  and click Import- If you do not know how to import click the link.

import-myshuttle2-ur...

2. After a few moments, the code will be imported.

  • Importing the MyShuttleCalc code from Github into VSTS.

In this task you will import the MyShuttleCalc code from Github into VSTS.

  1. Enter the following url: https://github.com/nwcadence/MyShuttleCalc.git and click Import.

import-myshuttlecalc...

2. After a few moments, the code will be imported.

  • Set up a Private Docker VSTS Build Agent
  1. In this you are going to configure a private build agent that runs in a Docker container.To setup Agent we require PAT, here is the link to generate the  PAT.
  2. When the token is created you will have to copy it - this is your only chance to see the token. Copy it from the browser into the clipboard. And Save it.
  • Starting a VSTS Agent Container using Docker

In this task you will start a VSTS build agent container using Docker. This container will be used to run builds and releases.

  1. Enter a command in terminal.
docker run -e VSTS_ACCOUNT= -e VSTS_TOKEN= -e DOCKER_CERT_PATH=/root/.docker -v /var/run/docker.sock:/var/run/docker.sock --name vstsagent -it vsts/agent.
  • Connect to VSTS from IntelliJ.
  1. Open the IntelliJ, Under select plugin Install "Visual Studio Team Services".

Capture6

  1. When IntelliJ restarts, the Welcome dialog will appear again. Click “Check out from Version Control” and select “Team Services Git”.

  2. Click on "Sign in..." to sign in to your VSTS account.

intellij-vsts-signin

  • Clone MyShuttle2 from VSTS with IntelliJ.
  1. Once you have authenticated, enter “MyShuttle2” into the search bar and select the MyShuttle2 repo from your team project. Click the Clone button to clone the repo to the VM.

intellij-select-repo

2. IntelliJ detects a Maven project file (pom.xml) and “Configure the SDK"

intellij-select-sdk

3. In Similar way clone MyShuttleCalc From VSTS with IntelliJ.

  • Maven Package Management with VSTS

Here, you are going to set up package management with Maven in VSTS. This repo contains a class library (MyShuttleCalc) that is used by the MyShuttle2 application. You will configure a VSTS build to publish the MyShuttleCalc package to a VSTS Maven Package feed so that it can be consumed by MyShuttle2.

  1. Create Maven Package Feed-If you do not know how to create Maven package click the Link.
  2. In VSTS, go back to the Connect to Feed dialog on your Maven feed.Click on the copy button in the section labeled add this feed to your project pom.xml inside the tag

maven-packagefeed-se...

3. In your editor, open the pom.xml file.Update the tag as well as the  tag so that they point to your feed.

pom-repo

4. Commit your changes to the IntelliJ.

  • Creating a VSTS Build for Publishing a Maven Package.

Here you will create a build that will publish the MyShuttleCalc library to the Maven feed

  1. Create a New Build Definition,Click on the Maven task. Edit the following settings:

Capture9

2. Click Save and Queue. Accept the defaults to queue the build.

3. When the build completes successfully, you can click on the build number to view the summary. Note the test results and code coverage.

build-summary

4. Navigate back to the Maven package feed. There you will see the MyShuttleCalc package.

package-in-feed

  • Build and Publish Docker Images.

Here, you are going to create a Docker Registry in Azure as well as a VSTS build that will build two Docker container images and publish then to the registry. In a later lab you will configure a Release in VSTS to run the containers.

  1. Create Azure Container Registry.

new-reg-settings

2. Will Update the Pom.xml file for MyShuttle2 application so that it can consume the MyShuttleCalc packages from the Maven package feed.

maven-packagefeed-se...

3. Click on the pom.xml file, In the repositories element there is a reference to a Maven repo. Paste in the repository settings you got from VSTS.

dependency

4. In IntelliJ Update the Project.

  • Create a VSTS Build to Build Docker Images.

Here you will create a VSTS build definition that will create two containers. The build will publish the containers to the Azure Container Registry you just created.

  1. create a new Build definition. And Select the Maven template. On the Get Sources step, ensure that the repo is MyShuttle2, and the branch is master. Toggle the Advanced Settings toggle and change Tag Sources to “On Success”.

get-sources-settings

2. Click on the Maven pom.xml step and edit the following values:

pom2

3. Click on the “Copy Files” task. Set the Contents property to:

copy

4. Under the list of tasks, click “Add Task”. Type “docker” into the search box and then click the Apply button next to the Docker Compose task and Configure the settings of the Docker Compose task as follows:

DockerCompose

5. Clone the Docker Compose Task and Update the action to “Push Services”.

6. Enable the Continuous Integration trigger.

7. Click the “Save and Queue” button to save and queue this build. Now You should see a successful build.

build-success

8. Navigate back to the Azure Portal and find your Azure Container Registry. Click on Repositories. You should see a db and a web repository.

container-reg-repos

  • Deploying to Azure.

Here, you are going to create a Release Definition that will start the container images from the build lab. You will then create an Azure Container Service (ACS) and modify the Release to start containers in ACS.

  1. Here you will install a VSTS extension from the VSTS Marketplace.This extension contains build and release tasks - you are going to use the ReplaceTokens task in the Release.
  2. Install “Colin’s ALM Corner Build & Release Tools”.

install-extension

  • Create a Release Definition

Here, you will create a Release Definition with a single environment. You will configure the release to run the MyShuttle application containers

  1. Create a Release Definition and select with empty process.
  2. Click on Environment1 to open the properties flyout. And change the name to “AzureVM”.

rename-env1

3. Click the “+” icon on the phase to add a new task. Type “replace” in the search box. Add a “Replace Tokens” task. And Set the following properties for the Replace Tokens task:

Capture10

4. Click the “+” icon on the phase to add a new task. Add a “Docker Compose” task. Set the following properties for the Docker Compose task:

Capture11

5. Click the “+” icon on the phase to add a new task. Add a “Command Line” task. Set the following properties for the Command Line task

Capture12

6. Click the “+” icon on the phase to add a new task. Add a “Publish Test Results” task. Set the following properties for the Publish Test Results task:

Capture13

7. Click on the Variables tab. Enter the following variables and scopes:

Capture3

8. Click the Save button. And Create Release.When the release completes, click on the Tests tab and then change the filter to see that the tests all succeeded.

Capture14

9. In Chrome, browse to http://localhost:8081/myshuttledev/ to see the site running.

site-running

Related

Roles in DevOps Mobile App Development

DevOps can be defined as an approach to enable seamless application delivery from inception to produ...

Read More >

What is DevOps and why Enterprises are serious about it?

The term DevOps is becoming increasingly familiar as more and more companies are interested in imple...

Read More >

How to Prevent Users from Moving Task to Closed State with a non-Zero value Remaining Work field in VSTS/TFS

In this Blog I am going to explain how we can customize Task in VSTS/TFS to Prevent Users from Movin...

Read More >

Implementing Security to your DevOps Pipeline

Hi all, today in this post I'm gonna talk about "Implementing Security to your DevOps Pipel...

Read More >

VSTS Rollup Service - How to use

          Hi All, Here i'm going to explain How VST...

Read More >

VSTS Rollup Service - Setup

Hi All, if you are worrying how to calculate sum of the effort fields in VSTS, here is the solution....

Read More >

VSTS Area Uploader

VSTS Area Uploader helps you to upload Areas (with multiple level) to your VSTS Team Projects from a...

Read More >

VSTS Copy Dashboard Tool

The Copy Dashboard tool replicates/copies the existing dashboard from one team to either single or m...

Read More >

Dashboard Migrator Tool

This is a web service which helps you to copy the VSTS dashboards from 1 team to another team easing...

Read More >

VSTS Team project Monitor

Let us discuss how to install VSTS team project monitor and how we can make use of it easily.Particu...

Read More >

Share

Post a Comment

  • Recent
  • Popular
  • Tag
Tags
Monthly Archive
Subscribe
Name

Contact Us
  • *
  • *