はじめに:Artifactoryとは
Artifactoryとは、パッケージマネージャである。
パッケージマネージャとは、パッケージ(ライブラリ)やアーティファクト(成果物、例えばwar)を登録できる製品のこと
この記事でできること
Artifactoryにmavenパッケージを登録(deploy)する際、同時にビルド情報を添付する
メリットとして、どのような環境からビルドしたのか把握できるようになる
スクリーンショット
どのバージョンをdeployしたかわかる
deploy時のメタデータを表示できる
事前準備
今回は、以下の設定で事前準備を行う。プロジェクトによりこの部分は変化するので、各自読み替えること。
- Artifactoryサーバのbase urlが
127.0.0.1:8082
である - 作成したリポジトリのキーが
lib-fw-nma-dev
である
結果、想定通りであればArtifactoryの画面が以下の状態となる
サーバ設定画面
リポジトリ画面
デプロイ情報画面
設定ファイル
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.nablarch.integration</groupId>
<artifactId>nablarch-micrometer-adaptor</artifactId>
<version>2.1.2-NEXT</version>
<distributionManagement>
<repository>
<id>central</id>
<name>77b467d8e820-releases</name>
<url>http://127.0.0.1:8081/artifactory/lib-fw-nma-dev</url>
</repository>
</distributionManagement>
<build>
<plugins>
<plugin>
<groupId>org.jfrog.buildinfo</groupId>
<artifactId>artifactory-maven-plugin</artifactId>
<version>3.6.1</version>
<executions>
<execution>
<id>build-info</id>
<goals>
<goal>publish</goal>
</goals>
<configuration>
<deployProperties>
</deployProperties>
<publisher>
<!-- リポジトリキーの組み合わせ -->
<contextUrl>http://localhost:8081/artifactory</contextUrl>
<username>${username}</username>
<password>${password}</password>
<repoKey>lib-fw-nma-dev</repoKey>
<publishArtifacts>true</publishArtifacts>
<publishBuildInfo>true</publishBuildInfo>
</publisher>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
settings.xml
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers>
<server>
<id>central</id>
<username>admin</username>
<password>******</password>
<configuration>
<authenticationInfo>
<userName>admin</userName>
<password>******</password>
</authenticationInfo>
</configuration>
</server>
</servers>
<profiles>
<profile>
<id>artifactory-plugin-properties</id>
<properties>
<username>admin</username>
<password>******</password>
</properties>
</profile>
</profiles>
<activeProfiles>
<activeProfile>artifactory-plugin-properties</activeProfile>
</activeProfiles>
</settings>
実行
mvn deploy
を行う
mvn deploy 出力例
ポイントは、Build-infoが出力されていること
[INFO] --- deploy:3.1.1:deploy (default-deploy) @ nablarch-micrometer-adaptor ---
[INFO] Skipping artifact deployment
[INFO] [pool-4-thread-1] Deploying artifact: http://localhost:8081/artifactory/lib-fw-nma-dev/com/nablarch/integration/nablarch-micrometer-adaptor/2.1.2-NEXT/nablarch-micrometer-adaptor-2.1.2-NEXT-sources.jar
[INFO] [pool-4-thread-1] Deploying artifact: http://localhost:8081/artifactory/lib-fw-nma-dev/com/nablarch/integration/nablarch-micrometer-adaptor/2.1.2-NEXT/nablarch-micrometer-adaptor-2.1.2-NEXT-javadoc.jar
[INFO] [pool-4-thread-1] Deploying artifact: http://localhost:8081/artifactory/lib-fw-nma-dev/com/nablarch/integration/nablarch-micrometer-adaptor/2.1.2-NEXT/nablarch-micrometer-adaptor-2.1.2-NEXT.jar
[INFO] [pool-4-thread-1] Deploying artifact: http://localhost:8081/artifactory/lib-fw-nma-dev/com/nablarch/integration/nablarch-micrometer-adaptor/2.1.2-NEXT/nablarch-micrometer-adaptor-2.1.2-NEXT.pom
[INFO] Artifactory Build info recorder: Deploying build info ...
[INFO] Deploying build info...
[INFO] Build-info successfully deployed. Browse it in Artifactory under http://localhost:8081/artifactory/webapp/builds/nablarch-micrometer-adaptor/1712480731656
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9.396 s
[INFO] Finished at: 2024-04-07T18:05:41+09:00
[INFO] ------------------------------------------------------------------------
参考情報へのリンク
公式docs:artifactory-maven-plugin
サンプルプロジェクト
スキーマ
clientConfiguration
blog: JFrog Artifactory無料版でアーティファクトを管理する方法