Skip to content

Commit

Permalink
feat: declare as step output the staging repository id
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasfara committed Jan 29, 2023
1 parent 5d26a60 commit 5a034ae
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,17 @@ private fun Project.configureNexusRepository(repoToConfigure: Repository, nexusU
doLast {
rootProject.warnIfCredentialsAreMissing(repoToConfigure)
nexusClient.nexusClient.repoUrl // triggers the initialization of a repository
// Write the staging repository ID to the Github env if on CI
if (System.getenv("CI") == true.toString()) {
exec {
it.commandLine(
"echo",
"${repoToConfigure.name}StagingRepositoryId=${nexusClient.nexusClient.repoId}",
">>",
"\$GITHUB_OUTPUT"
)
}
}
}
group = PublishingPlugin.PUBLISH_TASK_GROUP
description = "Creates a new Nexus staging repository on ${repoToConfigure.name}."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,10 @@ data class NexusStatefulOperation(
* Lazily computed staging repository descriptor.
*/
val stagingRepository: StagingRepositoryDescriptor by lazy {
project.properties["nexusStagingRepositoryId"]?.let {
project.properties["stagingRepositoryId"]?.let {
project.logger.lifecycle("Using existing staging repository {}", it)
return@lazy StagingRepositoryDescriptor(project.uri(nexusUrl), it as String)
val stagingRepo = client.getStagingRepositoryStateById(it as String)
return@lazy StagingRepositoryDescriptor(project.uri(nexusUrl), stagingRepo.id)
} ?: run {
project.logger.lifecycle("Creating repository for profile id {} on Nexus at {}", stagingProfile, nexusUrl)
client.createStagingRepository(
Expand Down

0 comments on commit 5a034ae

Please sign in to comment.