Continuing from the article below, I'll try using CircleCI this time. https://qiita.com/kasa_le/items/1b97b0d36c81785522a8
CircleCI You can register here. There is only a way to link with Github or Bitbucket, so please give up on other repositories (laugh) https://circleci.com/
There are a lot of templates, and a library-like thing that summarizes jobs called Orb is distributed, so it seems that the build environment of major places is in place. You can also build .NET, Android, etc.
The connection to Github is done as ** Authorized OAuth Apps **. It will be registered in [Settings]-[Applications]-[Authorized OAuth Apps] of your Github account. (Internally, it seems to be a connection with an SSH key.)
It also supports the cache function.
The OS image supports Linux, Windows, macOS, but I was able to pull various Docker images, which was helpful this time.
I think the free plan can withstand personal hobby use, but be aware that the OS image is only compatible with Linux or Windows. Other than that, you will be charged monthly.
https://circleci.com/ja/pricing/ It seems that the amount difference between the plans is large, but if you look at the bottom, it is a billing system (monthly amount) according to the number of team members and usage amount.
I think it's easy to estimate if the project has stable CI operation. On the other hand, for a project that is maintained and developed for a certain period of time and goes around a lot, but does not go around much during other operations, it costs a minimum monthly fee without doing anything, so I would like to identify and use that area.
And in the case of OSS
Offer 400,000 monthly credits to customers with free plans
However, it seems that only Linux can be used (from the FAQ at https://circleci.com/ja/pricing/), so be careful.
An on-premises version is also available for the enterprise (contact us). https://circleci.com/ja/enterprise/
It is an image of a long-established store. Therefore, it is currently version 2.1, but when I searched for it, I found a lot of information from the old days, and it was a little difficult to get to the information in the current version.
Also, it seems that the UI of the website is being changed, and the new UI and the old UI are transitioning in a mess, so I am quite confused as to "How do I get back to that screen?" It says that you won't be able to see the old screen after April 15th, so it may calm down after that.
The markdown information when attaching a status badge etc. provides a page where you can set your own project, branch name etc. and copy and paste it in the old UI, but in the new UI it is that It's a bit inconvenient because the page is gone and only the sample is on the general explanation page.
Also, I can't run the workflow manually. (Although you can [Rerun] the executed one)
Only use the yml
file.
Create a directory called .circleci
directly under the root of the project and place config.yml
under it.
Ultimately, here's a setup that worked well for build and testing.
.circleci/config.yml
version: 2.1
jobs:
build:
docker:
- image: 'cimg/openjdk:11.0.6'
steps:
- checkout
- run:
name: Build and test
command: mvn clean install
- store_artifacts:
path: repository/target/repository.jar
- store_artifacts:
path: serverapi/target/serverapi.war
- run:
name: Save test results
command: |
mkdir -p ~/test-results/junit/
find . -type f -regex ".*/target/surefire-reports/.*xml" -exec cp {} ~/test-results/junit/ \;
when: always
- store_test_results:
path: ~/test-results
- store_artifacts:
path: ~/test-results/junit
workflows:
version: 2
maven_test:
jobs:
- build:
filters:
branches:
only: feature/for_circleci
If you select Java (Maven)
in the first template, it will create one using Orb, but in this image it is said that there is no jar
in the submodule repository
, and it depends on it. The submodule build has failed.
I tried and errored because it seemed that I could specify the JDK version with ctag
of Executor for Orb, but I couldn't pass it well probably because I didn't understand yml
.
Therefore, by referring to the Orb source code and using the Docker image as described above, it became possible to build with the latest version of OpenJDK 11 (LTS version), and it became successful.
Maven Orb page https://circleci.com/orbs/registry/orb/circleci/maven
jar
and war
, there was a problem with pom.xml
on the Maven project side, so maybe that version worked with the default settings. Hmm.The steps are as follows.
build
--docker
section
--Specify the path of the image dropped from https://hub.docker.com/r/
--steps
section
checkout
--Check out the target branchBuild and test
--Execute the mvn clean install
commandstore_artifacts
--Save repository.jar
and serverapi.war
as artifacts (*)Save test results
--Copy the surefire test report of each module to one directory (*)store_test_results
--Archive test resultsstore_artifacts
--Save test results as artifactsFor the build
job, I have a filter setting that limits the branch to festival / for_circleci
.
The (*) part of the step explanation does not support wildcards and regular expression path specifications!
This is very troublesome ...
For example, in Maven pom, you can specify the file name of the product with the <build> <fileName>
tag, but this specification is optional. If not specified, the default is
repository-1.1-SNAPSHOP.jar
You can give it a name like this. It comes with a version. This is easier to understand, but if you do this, you will have to rewrite the artifact file name of yml
later when you upgrade the version, which is very inconvenient.
So this time, in this project, I tried to solve the problem by fixing it as repository.jar
with the<build> <fileName>
tag, but this will tell you the version after downloading the product. It may be difficult and difficult.
Recommended Posts