Tay*_*Rae 5 api groovy task amazon-s3 nexus3
当我尝试每周重新启动 Nexus3 容器并连接到我拥有的 S3 存储桶时,出现了这个问题。我将容器设置为可以很好地连接到 S3 存储桶(它[A-Z,0-9]-metrics.properties每次都会创建一个新文件),但在查看 UI 时找不到以前的工件。
我使用了Repair - Reconcile component database from blob storeUI 设置中的任务,效果非常好!
但是...前面的所有步骤都是通过脚本自动完成的,我希望Reconciling the blob store的最后一步也是如此。
Connecting to the S3 blob store is done with reference to examples from nexus-book-examples. As below:
Map<String, String> config = new HashMap<>()
config.put("bucket", "nexus-artifact-storage")
blobStore.createS3BlobStore('nexus-artifact-storage', config)
Run Code Online (Sandbox Code Playgroud)
AWS credentials are provided during the docker run step so the above is all that is needed for the blob store set up. It is called by a modified version of provision.sh, which is a script from the nexus-book-examples git page.
Is there a way to either:
小智 3
根据您使用的存储库管理器的特定版本,可能有用于列出和运行计划任务的 REST 端点。根据此票证,这是在 3.6.0 中引入的: https: //issues.sonatype.org/browse/NEXUS-11935。有关 3.x 中 REST 集成的更多信息,请查看以下内容: https: //help.sonatype.com/display/NXRM3/Tasks+API
为了创建计划任务,您必须添加一些常规代码。也许以下是一个好的开始:
import org.sonatype.nexus.scheduling.TaskConfiguration
import org.sonatype.nexus.scheduling.TaskInfo
import org.sonatype.nexus.scheduling.TaskScheduler
import groovy.json.JsonOutput
import groovy.json.JsonSlurper
class TaskXO
{
String typeId
Boolean enabled
String name
String alertEmail
Map<String, String> properties
}
TaskXO task = new JsonSlurper().parseText(args)
TaskScheduler scheduler = container.lookup(TaskScheduler.class.name)
TaskConfiguration config = scheduler.createTaskConfigurationInstance(task.typeId)
config.enabled = task.enabled
config.name = task.name
config.alertEmail = task.alertEmail
task.properties?.each { key, value -> config.setString(key, value) }
TaskInfo taskInfo = scheduler.scheduleTask(config, scheduler.scheduleFactory.manual())
JsonOutput.toJson(taskInfo)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1359 次 |
| 最近记录: |