Automatically publish to bintray after artifactory

This commit is contained in:
Tyler Benson 2017-09-07 10:22:36 -07:00
parent a790e7b9f7
commit 43436999c4
2 changed files with 27 additions and 34 deletions

View File

@ -27,28 +27,6 @@ description = 'dd-trace-java'
// Applied here to allow publishing of artifactory build info
apply from: "${rootDir}/gradle/publish.gradle"
// Source: https://github.com/ratpack/ratpack/blob/master/ratpack.gradle#L101
task bintrayPublish() {
doLast {
if (!project.hasProperty("bintrayApiKey") || bintrayApiKey.length() < 20) {
throw new InvalidUserDataException("You must provide a valid bintrayApiKey")
}
if (!project.hasProperty('buildNumber') || !"$buildNumber".isInteger()) {
throw new TaskExecutionException("Must provide buildNumber of a release from https://oss.jfrog.org/artifactory/webapp/#/builds/dd-trace-java")
}
def curl = [
'curl',
'-X', 'POST',
'-u', "${bintrayUser}:${bintrayApiKey}",
'-d', '',
"http://oss.jfrog.org/api/plugins/build/promote/snapshotsToBintray/dd-trace-java/$project.buildNumber"
].execute()
logger.info("Received response: ${curl.text}")
}
}
task wrapper(type: Wrapper) {
gradleVersion = '4.0'
}

View File

@ -73,6 +73,7 @@ artifactoryPublish { task ->
throw new IllegalStateException("cannot run " + task + " with --parallel and --max-workers > 1")
}
}
}
artifactory {
publish {
@ -83,17 +84,27 @@ artifactoryPublish { task ->
else
repoKey = isSnapshot ? 'oss-snapshot-local' : 'oss-release-local'
gradle.taskGraph.whenReady { taskGraph ->
artifactoryPublish { task ->
if (taskGraph.hasTask(task)) {
username = bintrayUser
password = bintrayApiKey
}
}
}
}
defaults {
if (!isRoot) publishConfigs('archives')
}
}
}
bintrayUpload { task ->
gradle.taskGraph.whenReady { taskGraph ->
def startParameter = project.gradle.startParameter
if (taskGraph.hasTask(task) && startParameter.parallelProjectExecutionEnabled && startParameter.maxWorkerCount > 1) {
throw new IllegalStateException("cannot run " + task + " with --parallel and --max-workers > 1")
}
}
}
bintray {
@ -156,3 +167,7 @@ bintray {
// }
}
}
if(!isSnapshot) {
artifactoryPublish.finalizedBy bintrayUpload
}