2017-09-07 14 views
0

私たちは最新のリリースのnexusを使用していますので、私はクリーンアップタスクを作成します。Nexus Sonatypeのgroovyでアセットとコンポーネントを削除

私は、トランザクションオブジェクトから取得した反復可能なコンポーネントリストを実行するグ​​ルーヴィースクリプトを持っています。

私はコンポーネントにアセットを見つけて、アセットとコンポーネントを削除したいと思います。

私のスクリプトは次のようになります。

// Get a repository 
def repo = repository.repositoryManager.get('maven-releases'); 
// Get a database transaction 
def tx = repo.facet(StorageFacet).txSupplier().get(); 
// Begin the transaction 
tx.begin(); 

def components = tx.browseComponents(tx.findBucket(repo)); 

// retention date 
def retentionDate = new DateTime(); 
retentionDate.minusDays(1); 

components.each{comp -> 
    def lastComp = comp.group() + comp.name(); 
    def lastModDate = comp.lastUpdated(); 

    if(lastModDate.isBefore(retentionDate)) { 
     // here ----------- 
     // tx.deleteAsset(<asset>) 
     // ----------------- 
     tx.deleteComponent(comp); 
     log.info("${lastComp} deleted!"); 
    } 

    log.info("anz: ${assetCount} ${comp.version()} - ${lastModDate} - ${retentionDate}"); 
} 

// End the transaction*/ 
tx.commit(); 

それはコンポーネントに対応する資産を見つけることは可能ですか?

答えて

0

これは簡単だった:

Asset asset = tx.findAsset(comp.entityMetadata.getId(), tx.findBucket(repo)); 
関連する問題