[JAVA] CI for Maven project in Azure Pipelines

In the continuation of the following article, this time I will try using Azure Pipelines. https://qiita.com/kasa_le/items/b152f91a61315a2b12b2

Azure Pipelines Needless to say, it is the CI included in Azure DevOps in Microsoft's cloud service Azure. https://azure.microsoft.com/ja-jp/services/devops/

Feature

You can connect not only to Azure Repos (Azure Git repository service) but also to Github and general-purpose Git (*). Naturally, the build environment for .NET and C # projects is substantial, and Windows developers will actually have a choice between AppVeyor and this one. However, until a while ago, there was only AppVeyor, so it would be nice to have a choice. It's also true that the integration with Visual Studio and Visual Studio Code and the extensions are substantial.

Fee

With Azure Pipelines only, up to 5 users can use 1 parallel job for up to 1,800 minutes a month for free. In the case of self-hosted, there is no monthly usage limit (1 parallel job). I use Azure Artifacts to upload the artifacts, and I can use up to 2GB for free.

For more details, here. https://azure.microsoft.com/ja-jp/pricing/details/devops/azure-devops-services/

Performance

Well, after all, it's Microsoft (sweat)

I don't care, but the e-learning course is very tiring to read in story format (bitter smile) Only English is available, but it's strange even if it's in Japanese, so maybe I didn't prepare a translation ^^;

Setting

There are two ways, one is to use the Classic Editor and the other is to write a yml file. For basic Maven builds and tests, you can just select ** Maven ** in the template. The following are the template default settings in YAML mode. JerseySample was able to go with this setting.

azure-pipelines.yml


# Maven
# Build your Java project and run tests with Apache Maven.
# Add steps that analyze code, save build artifacts, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/java

trigger:
- master

pool:
  vmImage: 'ubuntu-latest'

steps:
- task: Maven@3
  inputs:
    mavenPomFile: 'pom.xml'
    mavenOptions: '-Xmx3072m'
    javaHomeOption: 'JDKVersion'
    jdkVersionOption: '1.11'
    jdkArchitectureOption: 'x64'
    publishJUnitResults: true
    testResultsFiles: '**/surefire-reports/TEST-*.xml'
    goals: 'package'

You can check the test results on the pipeline page.

azule-pipelines-test-summary.PNG

It's unpleasant that Version 11 must be specified as 1.11 by specifying jdkVersionOption (sweat)

Like Github, OpenJDK uses Azul Zulu. (Azul Zulu is basically paid, but it's free to use with Azure Pipelines. What? Github Actions ??) https://github.com/actions/virtual-environments/blob/master/images/linux/Ubuntu1804-README.md

Due to various circumstances, it is necessary to be able to build with AdoptOpenJDK, so I checked if it could be included, but there was a person who published a convenient extension. https://marketplace.visualstudio.com/items?itemName=hanabi1224.adopt-openjdk-installer

atopdopenjdk_marketplase.png

This can be used from ** Classic Editor **. The Classic Editor has a small link on the first page called Classic Editor instead of YAML when you create a Pipeline, so you can use it by clicking on it.

azule-pipelines-classic-editor.PNG

You can also refer to the yml after making it with Classic Editor.

azule-pipelines-view-yaml.PNG

However, Classic Editor has been deprecated, so it's safe to leave it in the menu at any time.

Impressions

The operation is relatively easy, but the menu structure requires some getting used to.

I have to do some tutorials in English learning paths and the following articles. , It may be difficult to understand where and what is. https://docs.microsoft.com/ja-jp/azure/devops/pipelines/create-first-pipeline?view=azure-devops&tabs=java%2Cyaml%2Cbrowser%2Ctfs-2018-2

Personally, I felt that the test results were the easiest to see. It's also nice to have buttons that are easy to understand to run manually.

It's good that it seems easy to integrate with Slack. Individuals and small teams can get a free tier, and if you already have a subscription, it's easy to use.

By the way, Azure Pipelines was the fastest compared to other CI services from the initial setup to the build, test run, and view of the test results.

** Addition ** After turning CI, a PR was created on Github and a display was added to the Check page.

azure_pipelines_github_pr.png

This seems convenient, but I don't like creating PR every time, so I need to do some research ...

Recommended Posts

CI for Maven project in Azure Pipelines
CI for Maven project on AppVeyor
CI for Maven project at CircleCI
CI for Maven project at Github Actions
Run JUnit and Spock in a maven project
CI / CD practice for beginners --Part3 --Preparation for development project
Azure functions in java
Reload dependencies in Maven
Create Maven Web Project
Create a base for your batch processing project in Eclipse.