diff --git a/nexus/src/main/kotlin/com/vanniktech/maven/publish/nexus/Nexus.kt b/nexus/src/main/kotlin/com/vanniktech/maven/publish/nexus/Nexus.kt index 84412351..4951c8fc 100644 --- a/nexus/src/main/kotlin/com/vanniktech/maven/publish/nexus/Nexus.kt +++ b/nexus/src/main/kotlin/com/vanniktech/maven/publish/nexus/Nexus.kt @@ -200,8 +200,26 @@ class Nexus( break } if (repository?.type == "open" && !repository.transitioning && repository.notifications > 0) { - val url = baseUrl.toHttpUrl().newBuilder("/#stagingRepositories").toString() - throw IOException("Closing the repository failed. ${repository.notifications} messages are available on $url") + val properties = try { + val response = service.getRepositoryActivity(repositoryId).execute() + if (response.isSuccessful) { + response.body()?.find { it.name == "close" } + ?.events?.find { it.name == "ruleFailed" } + ?.properties?.filter { it.name == "failureMessage" } + } else { + emptyList() + } + } catch (_: IOException) { + emptyList() + } + + if (properties.isNullOrEmpty()) { + val url = baseUrl.toHttpUrl().newBuilder("/#stagingRepositories").toString() + throw IOException("Closing the repository failed. ${repository.notifications} messages are available on $url") + } else { + val message = properties.joinToString("\n") { it.value } + throw IOException("Closing the repository failed with the following errors:\n$message") + } } } } diff --git a/nexus/src/main/kotlin/com/vanniktech/maven/publish/nexus/NexusModel.kt b/nexus/src/main/kotlin/com/vanniktech/maven/publish/nexus/NexusModel.kt index 8b6742c4..669b363e 100644 --- a/nexus/src/main/kotlin/com/vanniktech/maven/publish/nexus/NexusModel.kt +++ b/nexus/src/main/kotlin/com/vanniktech/maven/publish/nexus/NexusModel.kt @@ -28,6 +28,15 @@ internal data class Repository( val notifications: Int ) +@JsonClass(generateAdapter = true) +internal data class RepositoryEventProperty(val name: String, val value: String) + +@JsonClass(generateAdapter = true) +internal data class RepositoryEvent(val name: String, val properties: List) + +@JsonClass(generateAdapter = true) +internal data class RepositoryActivity(val name: String, val events: List) + @JsonClass(generateAdapter = true) internal data class ProfileRepositoriesResponse(val data: List) diff --git a/nexus/src/main/kotlin/com/vanniktech/maven/publish/nexus/NexusService.kt b/nexus/src/main/kotlin/com/vanniktech/maven/publish/nexus/NexusService.kt index 6e9a4b17..ad34f47d 100644 --- a/nexus/src/main/kotlin/com/vanniktech/maven/publish/nexus/NexusService.kt +++ b/nexus/src/main/kotlin/com/vanniktech/maven/publish/nexus/NexusService.kt @@ -27,6 +27,9 @@ internal interface NexusService { @GET("staging/repository/{repositoryId}") fun getRepository(@Path("repositoryId") repositoryId: String): Call + @GET("staging/repository/{repositoryId}/activity") + fun getRepositoryActivity(@Path("repositoryId") repositoryId: String): Call> + @POST("staging/bulk/close") fun closeRepository(@Body input: TransitionRepositoryInput): Call