[JAVA] CI for Maven project on AppVeyor

It is a memorandum because I investigated the Maven + Java project created in the following article with the intention of turning it with CI. https://qiita.com/kasa_le/items/db0d84e3e868ff14bc2b

AppVeyor

You can register here. https://www.appveyor.com/

Feature

Basically, it seems that the main purpose is to build on Windows or Visual Studio.

You can also connect to Git other than Github, GitLab, and Bitbucket. (* However, there are some restrictions. See below) Also, I had to connect to SSH with Git, but AppVeyor also supports this.

It also supports cache.

There are also macOS (Catalina, Majave) and Ubuntu in the OS image, but I had a lot of trouble because there was no template for Maven build or something like that.

Fee

Free if open source. Other than that, it is basically a monthly charge. If the project seems to be up and running, but it has expired, it may be good because it is easy to estimate the cost. There is no particular mention of the number of team members, so I think there is no limit. https://www.appveyor.com/docs/team-setup/

Performance

Sakura editor is famous as a text editor that is easy to use on Windows, but it seems that AppVeyor is used. (It seems to be used with Azure Pipelines)

Setting

Basically, CI jobs are defined by placing a file called ʻappveyor.yml` directly under the root of the project.

1. Change MS build settings

The first thing to do is that the build is an MS build (for Visual Studio), so you need to unset it from your browser.

--Open the project page and select [Build] on the [Settings] tab.

appveyor_msbuild_off.png

--Select [Script] next to [MSBuild]

appveyor_script_select.png

--Click [Save]

This completes the preparation.

2. Create ʻappveyor.yml`

For the time being, here is ʻappveyor.yml`, which was finally built and tested successfully.

appveyor.yml


# Branches
branches:
  only:
  - feature/for_ci_test
image: ubuntu

install: 
- sh: sudo add-apt-repository --yes ppa:rpardini/adoptopenjdk
- sh: sudo apt-get update
- sh: sudo apt-get install -y adoptopenjdk-11-jdk-hotspot-installer
- sh: sudo apt install adoptopenjdk-11-jdk-hotspot-set-default
#/usr/lib/jvm/adoptopenjdk-11-jdk-hotspot
- sh: export JAVA_HOME=/usr/lib/jvm/adoptopenjdk-11-jdk-hotspot
- sh: echo $JAVA_HOME
- sh: export PATH=${PATH}

before_build:
- mvn -v

build_script:
- mvn clean package -DskipTests

test_script:
- mvn install verify

on_finish:
  - sh: |
      find "$APPVEYOR_BUILD_FOLDER" -type f -name 'TEST*.xml' -print0 | xargs -0 -I '{}' curl -F 'file=@{}' "https://ci.appveyor.com/api/testresults/junit/$APPVEYOR_JOB_ID"
      
artifacts:
  - path: "**/target/*.?ar"

version: "1.1.{build}"

The contents are as follows,

--branches section --Run only on the feature / for_ci_test branch

If you commit and push this directly under the root of the project, CI will start running.

Since it can be cached, it may be good to target Java folders. In that case, you need to rewrite the sh command part to decide whether to install jdk depending on the presence or absence of the cache.

Precautions when connecting to Git other than Git repository service

In the Github repository, if you put the above ʻappveyor.yml, it builds using it, but when connecting to Git other than the repository services ** such as Github, GitLab, Bitbucket ** (for example, your company) (Git server etc. set up in) is placed in the project ʻappveyor.yml Did not seem to see me at all.

For the time being, similar settings can be set from the browser, but it was a lot of work because I had to set it here and there across pages, and I could not reach the itchy place, so I will consider using it. Be careful if you do.

Impressions

Originally it was for builds in Visual Studio, so it was also for projects such as C #, and I had the impression that other than that, there was not much focus. I honestly thought it would be better to consider a CI service that is rich in those templates.

Also, my sample project (JerseySample) passed both build and test, but another project running in the same environment could not be passed in the following state.

OS image phenomenon
On windows Will it crash during a Maven build?Exit 1Resulting in
on macOS Maven builds stop responding or builds never end
On ubuntu Will it crash in the middle of the test?Exit 1Resulting in(※手元のOn ubuntuではビルドもテストも正常終了する

Recommended Posts

CI for Maven project on AppVeyor
CI for Maven project at CircleCI
CI for Maven project at Github Actions
CI for Maven project in Azure Pipelines
Create Maven Project
Maven on CentOS 7 tutorial
CI / CD practice for beginners --Part3 --Preparation for development project
Create Maven Web Project
Introduce Maven to Tomcat project
[For super beginners] Maven super introduction
Must-see for beginners! How to manage your Xcode project on Github
[Eclipse / github] Let's share the project created with eclipse on github For beginners