LoginSignup
1
0

More than 5 years have passed since last update.

NexusのSnapshotsリポジトリのアーティファクトをデプロイする方法

Posted at

NexusのSnapshotsやReleasesリポジトリに登録されるアーティファクトには、
ダウンロード用にURLが付与される。

このURLを用いて、curlやwgetなどでサーバにアーティファクトをデプロイする上で、
Snapshotsリポジトリに関しては1点問題がある。

Snapshotsリポジトリに登録されるアーティファクトのURLには、
末尾のファイル名に、日付から開始する乱数が付与されるため、
アーティファクトの登録前はURLが分からない。

これは事前にダウンロードする先のURL指定をデプロイのためのスクリプトで
書けない(自動化出来ない)ことを意味する。

以下、NexusのAPIを使う方法で解決できる。

$ wget -O <ダウンロード後の資材名> --content-disposition --no-check-certificate ¥
--user <Nexusログインユーザ> --password <Nexusログインパスワード> ¥
https://<URL>/service/local/artifact/maven/content?r=<repository id>¥
\&g=<groupID>\&a=<アーティファクトID>\&v=<Version>\&p=<packaging>

$ wget -O sample.war --content-disposition --no-check-certificate --user hoge ¥
--password hoge https://x.x.x.x/nexus/service/local/artifact/maven/content?¥
r=snapshots\&g=sampleproject-webapp\&a=sample\&v=1.0.0-SNAPSHOT\&p=war

※上記コマンドで、Snapshotsリポジトリにある最新版のWarが取得可能となる
※なお、Releasesも上記のフォーマットに従い、repository id以降を適宜変更すれば、適用可能となる
※参考URL
https://support.sonatype.com/hc/en-us/articles/213465488-How-can-I-retrieve-a-snapshot-if-I-don-t-know-the-exact-filename-

1
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
1
0