0
0

Artifactory7-OSS: MavenパッケージをDeployしつつ、BuildInfoを添付する方法

Last updated at Posted at 2024-04-07

はじめに:Artifactoryとは

Artifactoryとは、パッケージマネージャである。
パッケージマネージャとは、パッケージ(ライブラリ)やアーティファクト(成果物、例えばwar)を登録できる製品のこと

この記事でできること

Artifactoryにmavenパッケージを登録(deploy)する際、同時にビルド情報を添付する
メリットとして、どのような環境からビルドしたのか把握できるようになる

スクリーンショット

どのバージョンをdeployしたかわかる

image.png

deploy時のメタデータを表示できる

image.png

事前準備

今回は、以下の設定で事前準備を行う。プロジェクトによりこの部分は変化するので、各自読み替えること。

  • Artifactoryサーバのbase urlが127.0.0.1:8082である
  • 作成したリポジトリのキーがlib-fw-nma-devである

結果、想定通りであればArtifactoryの画面が以下の状態となる

サーバ設定画面

image.png

リポジトリ画面

image.png

デプロイ情報画面

image.png

設定ファイル

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無料版でアーティファクトを管理する方法

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0