2017-03-18 6 views
1

多分私は何かが恋しいですが、UIからコンポーネント(jarまたはdll)をnexus 3リポジトリにアップロードする方法を見つけることができません。そこで、私はアップロードプロセスを最適化するためにこの仕事のためのツールを作ろうとしています。コンポーネントがNexusリポジトリにプログラム的に存在するかどうかを確認する方法が必要です。Nexus 3コンポーネントが存在するかどうかを確認するためにAPIをリセット

誰でもお勧めしますか?

答えて

1

現時点では、REST APIはベータ版としてリリースされています。 http://blog.sonatype.com/nexus-repository-new-beta-rest-api-for-content

いくつかの新しいエンドポイントを使用して、コンポーネント/アセットが存在するかどうかを確認し、アップロードするフォーマットに応じてカールまたは類似のものを使用することができますそれは既存のフォーマットエンドポイントを経由します。

2

groovyスクリプトをアップロードし、そのスクリプトを使用してコンポーネントが存在するかどうかを確認することができます。

import org.sonatype.nexus.repository.storage.Query; 
import org.sonatype.nexus.repository.storage.StorageFacet; 
import groovy.json.JsonOutput; 

def repositoryId = args.split(',')[0]; 
def groupId = args.split(',')[1]; 
def artifactId = args.split(',')[2]; 
def baseVersion = args.split(',')[3]; 
def latestOnly = args.split(',')[4]; 

def repo = repository.repositoryManager.get(repositoryId); 
StorageFacet storageFacet = repo.facet(StorageFacet); 
def tx = storageFacet.txSupplier().get(); 

tx.begin(); 
def components = tx.findComponents(Query.builder().where('group = ').param(groupId).and('name = ').param(artifactId).build(), [repo]); 

def found = components.findAll{it.attributes().child('maven2').get('baseVersion')==baseVersion}.collect{ 
def version = it.attributes().child('maven2').get('version');\"${version}\"}; 

// found = found.unique().sort(); 
def latest = found.isEmpty() ? found : found.last(); 

tx.commit(); 
def result = latestOnly == 'latest' ? JsonOutput.toJson(latest) : JsonOutput.toJson(found); 

return result; 
関連する問題