2017-03-18 2 views
1

어쩌면 내가 누락되었지만 UI에서 구성 요소 (jar 또는 dll)를 nexus 3 저장소로 업로드하는 방법을 찾을 수 없습니다. 그래서 업로드 작업을 최적화하기 위해이 작업을위한 도구를 만들려고합니다. 구성 요소가 프로그래밍 방식으로 nexus 저장소에 존재하는지 확인하는 방법이 필요합니다. 적절한 나머지 API를 찾으려는 모든 시도가 실패했습니다.Nexus 3 구성 요소가 존재하는지 확인하기 위해 API 다시 놓기

누구든지 의견이 있으십니까?

답변

1

현재 REST API는 베타 버전으로 출시되었습니다. 당신은 더 많은 정보를 얻을이 링크로 이동하여 우리에게 피드백을 제공 할 수 있습니다 http://blog.sonatype.com/nexus-repository-new-beta-rest-api-for-content 당신은 구성 요소/자산이 존재하는지 확인하고 업로드 형식에 컬 또는 유사한 것을 따라 사용하는 새로운 엔드 포인트의 일부를 사용할 수 있습니다

그것은 기존 형식 엔드 포인트를 통해 가능합니다.

2

그루비 스크립트를 업로드하고 해당 스크립트를 사용하여 구성 요소의 존재 여부를 확인할 수 있습니다.

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; 
관련 문제