aboutsummaryrefslogtreecommitdiffstats
path: root/build.gradle
diff options
context:
space:
mode:
Diffstat (limited to 'build.gradle')
-rw-r--r--build.gradle42
1 files changed, 31 insertions, 11 deletions
diff --git a/build.gradle b/build.gradle
index 7ecd7e2ba1d..431cb948799 100644
--- a/build.gradle
+++ b/build.gradle
@@ -63,22 +63,42 @@ allprojects {
repositories {
def repository = project.hasProperty('qa') ? 'sonarsource-qa' : 'sonarsource'
+ // The environment variables ARTIFACTORY_PRIVATE_USERNAME and ARTIFACTORY_PRIVATE_PASSWORD are used on QA env (Jenkins)
+ // On local box, please add artifactoryUsername and artifactoryPassword to ~/.gradle/gradle.properties
+ def artifactoryUsername = System.env.'ARTIFACTORY_PRIVATE_USERNAME' ?: (project.hasProperty('artifactoryUsername') ? project.getProperty('artifactoryUsername') : '')
+ def artifactoryPassword = System.env.'ARTIFACTORY_PRIVATE_PASSWORD' ?: (project.hasProperty('artifactoryPassword') ? project.getProperty('artifactoryPassword') : '')
+ def artifactoryUrl = System.getenv('ARTIFACTORY_URL') ?: (project.hasProperty('artifactoryUrl') ? project.getProperty('artifactoryUrl') : '')
+
+ if (artifactoryUrl == '') {
+ throw new GradleException('Invalid artifactoryUrl')
+ }
+
maven {
- // The environment variables ARTIFACTORY_PRIVATE_USERNAME and ARTIFACTORY_PRIVATE_PASSWORD are used on QA env (Jenkins)
- // On local box, please add artifactoryUsername and artifactoryPassword to ~/.gradle/gradle.properties
- def artifactoryUsername = System.env.'ARTIFACTORY_PRIVATE_USERNAME' ?: (project.hasProperty('artifactoryUsername') ? project.getProperty('artifactoryUsername') : '')
- def artifactoryPassword = System.env.'ARTIFACTORY_PRIVATE_PASSWORD' ?: (project.hasProperty('artifactoryPassword') ? project.getProperty('artifactoryPassword') : '')
- if (!artifactoryUsername || ! artifactoryPassword) {
-
- // Workaround for artifactory
- // https://www.jfrog.com/jira/browse/RTFACT-13797
- repository = 'public'
- }
- url "https://repox.jfrog.io/repox/${repository}"
+ if (artifactoryPassword) {
+ authentication {
+ header(HttpHeaderAuthentication)
+ }
+ credentials(HttpHeaderCredentials) {
+ name = "Authorization"
+ value = "Bearer $artifactoryPassword"
+ }
+ } else {
+ // Workaround for artifactory
+ // https://www.jfrog.com/jira/browse/RTFACT-13797
+ repository = 'public'
+ }
+ url "${artifactoryUrl}/${repository}"
}
ivy {
if (artifactoryUsername && artifactoryPassword) {
url "${artifactoryUrl}/sonarsource-bucket"
+ authentication {
+ header(HttpHeaderAuthentication)
+ }
+ credentials(HttpHeaderCredentials) {
+ name = "Authorization"
+ value = "Bearer $artifactoryPassword"
+ }
patternLayout {
artifact '/[organisation]/[module]/[module]-[revision].[ext]'