diff --git a/Jenkinsfile b/Jenkinsfile index c416b3bd8..b1a184a4a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -20,7 +20,7 @@ pipeline { } stage('Deploy Artifacts') { steps { - sh './gradlew publish' + sh 'export MAVEN_DEPLOYMENT=true; ./gradlew publish' } } } diff --git a/api/build.gradle b/api/build.gradle index 18ec5eb48..4ea731242 100644 --- a/api/build.gradle +++ b/api/build.gradle @@ -58,11 +58,16 @@ publishing { } } - // TODO: Set up a Maven repository on Velocity's infrastructure, preferably something lightweight. - /*repositories { - maven { - name = 'myRepo' - url = "file://${buildDir}/repo" + if (System.getenv("MAVEN_DEPLOYMENT") != null && project.ext.getCurrentBranchName() == "master") { + repositories { + maven { + name = 'myRepo' + if (project.version.toString().endsWith("-SNAPSHOT")) { + url = "file:///maven-repo/snapshots" + } else { + url = "file:///maven-repo/releases" + } + } } - }*/ + } } diff --git a/build.gradle b/build.gradle index 0b46cc4c2..ae5c1ff9a 100644 --- a/build.gradle +++ b/build.gradle @@ -16,6 +16,17 @@ allprojects { log4jVersion = '2.11.0' nettyVersion = '4.1.28.Final' guavaVersion = '25.1-jre' + + getCurrentBranchName = { + new ByteArrayOutputStream().withStream { os -> + exec { + executable = "git" + args = ["rev-parse", "--abbrev-ref", "HEAD"] + standardOutput = os + } + return os.toString() + } + } } repositories {