Skip to content

Commit 761de8d

Browse files
Publish: to Central instead of Bintray.
1 parent 78e6133 commit 761de8d

File tree

2 files changed

+23
-10
lines changed

2 files changed

+23
-10
lines changed

Jenkinsfile

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,7 @@ def internalRepoArgs = '-PinternalObjectBoxRepo=$MVN_REPO_URL ' +
1313
def uploadRepoArgs = '-PpreferredRepo=$MVN_REPO_UPLOAD_URL ' +
1414
'-PpreferredUsername=$MVN_REPO_LOGIN_USR ' +
1515
'-PpreferredPassword=$MVN_REPO_LOGIN_PSW '
16-
// Note: add quotes around URL parameter to avoid line breaks due to semicolon in URL.
17-
def uploadRepoArgsBintray = '\"-PpreferredRepo=$BINTRAY_URL\" ' +
18-
'-PpreferredUsername=$BINTRAY_LOGIN_USR ' +
19-
'-PpreferredPassword=$BINTRAY_LOGIN_PSW'
16+
def uploadRepoArgsCentral = '-PsonatypeUsername=$OSSRH_LOGIN_USR -PsonatypePassword=$OSSRH_LOGIN_PSW'
2017

2118
// https://jenkins.io/doc/book/pipeline/syntax/
2219
pipeline {
@@ -73,21 +70,24 @@ pipeline {
7370
}
7471
}
7572

76-
stage('upload-to-bintray') {
73+
stage('upload-to-central') {
7774
when { expression { return isPublish } }
7875
environment {
79-
BINTRAY_URL = credentials('bintray_url')
80-
BINTRAY_LOGIN = credentials('bintray_login')
76+
OSSRH_LOGIN = credentials('ossrh-login')
8177
}
8278
steps {
8379
googlechatnotification url: 'id:gchat_java',
84-
message: "*Publishing* ${currentBuild.fullDisplayName} to Bintray...\n${env.BUILD_URL}"
80+
message: "*Publishing* ${currentBuild.fullDisplayName} to Central...\n${env.BUILD_URL}"
8581

82+
// Step 1: upload files to staging repository.
8683
// Note: supply internal repo as tests use native dependencies that might not be published, yet.
87-
sh "./gradlew $gradleArgs $internalRepoArgs $uploadRepoArgsBintray uploadArchives"
84+
sh "./gradlew $gradleArgs $internalRepoArgs $uploadRepoArgsCentral uploadArchives"
85+
86+
// Step 2: close and release staging repository.
87+
sh "./gradlew $gradleArgs $uploadRepoArgsCentral closeAndReleaseRepository"
8888

8989
googlechatnotification url: 'id:gchat_java',
90-
message: "Published ${currentBuild.fullDisplayName} successfully to Bintray - check https://bintray.com/objectbox/objectbox\n${env.BUILD_URL}"
90+
message: "Published ${currentBuild.fullDisplayName} successfully to Central - check https://repo1.maven.org/maven2/io/objectbox/ in a few minutes.\n${env.BUILD_URL}"
9191
}
9292
}
9393

build.gradle

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ buildscript {
4242
classpath "org.jetbrains.dokka:dokka-gradle-plugin:$dokka_version"
4343
// https://github.com/spotbugs/spotbugs-gradle-plugin/releases
4444
classpath "gradle.plugin.com.github.spotbugs.snom:spotbugs-gradle-plugin:4.5.1"
45+
classpath "io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.22.0"
4546
}
4647
}
4748

@@ -187,3 +188,15 @@ configure(subprojects.findAll { projectNamesToPublish.contains(it.name) }) {
187188
wrapper {
188189
distributionType = Wrapper.DistributionType.ALL
189190
}
191+
192+
// Plugin to close and promote staging repository to Central.
193+
apply plugin: 'io.codearte.nexus-staging'
194+
nexusStaging {
195+
if (project.hasProperty("sonatypeUsername") && project.hasProperty("sonatypePassword")) {
196+
println('nexusStaging credentials supplied.')
197+
username = sonatypeUsername
198+
password = sonatypePassword
199+
} else {
200+
println('nexusStaging credentials NOT supplied.')
201+
}
202+
}

0 commit comments

Comments
 (0)