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
- 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.
- 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.
- 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.
- 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
- You will need a Visual Studio Team Services (VSTS) account - if you do not have one, you can create one now.
- 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
- Enter the following url:
https://github.com/nwcadence/MyShuttle2.git and click Import- If you do not know how to import click the link.
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.
- Enter the following url:
https://github.com/nwcadence/MyShuttleCalc.git and click Import.
2. After a few moments, the code will be imported.
- Set up a Private Docker VSTS Build Agent
- 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.
- 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.
- 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.
- Open the IntelliJ, Under select plugin Install "Visual Studio Team Services".
When IntelliJ restarts, the Welcome dialog will appear again. Click “Check out from Version Control” and select “Team Services Git”.
Click on "Sign in..." to sign in to your VSTS account.
- Clone MyShuttle2 from VSTS with IntelliJ.
- 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.
2. IntelliJ detects a Maven project file (pom.xml) and “Configure the 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.
- Create Maven Package Feed-If you do not know how to create Maven package click the Link.
- 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
3. In your editor, open the pom.xml file.Update the tag as well as the tag so that they point to your feed.
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
- Create a New Build Definition,Click on the Maven task. Edit the following settings:
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.
4. Navigate back to the Maven package feed. There you will see the MyShuttleCalc package.
- 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.
- Create Azure Container Registry.
2. Will Update the Pom.xml file for MyShuttle2 application so that it can consume the MyShuttleCalc packages from the Maven package feed.
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.
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.
- 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”.
2. Click on the
Maven pom.xml step and edit the following values:
3. Click on the “Copy Files” task. Set the Contents property to:
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:
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.
8. Navigate back to the Azure Portal and find your Azure Container Registry. Click on Repositories. You should see a
db and a
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.
- 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.
- Install “Colin’s ALM Corner Build & Release Tools”.
- 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
- Create a Release Definition and select with empty process.
- Click on Environment1 to open the properties flyout. And change the name to “AzureVM”.
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:
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:
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
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:
7. Click on the Variables tab. Enter the following variables and scopes:
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.
9. In Chrome, browse to
http://localhost:8081/myshuttledev/ to see the site running.