-
Notifications
You must be signed in to change notification settings - Fork 0
/
publish-internal.gradle
58 lines (54 loc) · 1.72 KB
/
publish-internal.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
apply plugin: 'maven-publish'
ext {
snapServiceAccount = ''
snapInternalRegistry = ''
snapInternalRegistry = ''
snapInternalRegistryUrl = ''
snapInternalRegistryUsername = ''
}
File secretPropsFile = project.rootProject.file('local.properties')
if (secretPropsFile.exists()) {
Properties p = new Properties()
secretPropsFile.withInputStream { stream ->
p.load(stream)
}
p.each { name, value ->
project.ext[name] = value
}
} else {
project.ext['snapServiceAccount'] = System.getenv('SNAP_SERVICE_ACCOUNT')
project.ext['snapInternalRegistry'] = System.getenv('SNAP_INTERNAL_REGISTRY')
project.ext['snapInternalRegistryUrl'] = System.getenv('SNAP_INTERNAL_REGISTRY_URL')
project.ext['snapInternalRegistryUsername'] = System.getenv('SNAP_INTERNAL_REGISTRY_USERNAME')
}
def getLcaToken = {
def stdout = new ByteArrayOutputStream()
exec {
commandLine '/home/jenkins/bin/lcaexec', 'issue', 'google', "${project.snapServiceAccount}", "${project.snapInternalRegistry}"
standardOutput = stdout
}
return stdout.toString().trim()
}
publishing {
publications {
mavenJava(MavenPublication) {
groupId = project.PUBLISH_GROUP_ID
artifactId = project.PUBLISH_ARTIFACT_ID
version = project.PUBLISH_VERSION
from components.java
}
}
repositories {
maven {
name = 'Internal'
url "${project.snapInternalRegistryUrl}"
authentication {
basic(BasicAuthentication)
}
credentials {
username = "${project.snapInternalRegistryUsername}"
password = getLcaToken()
}
}
}
}