Skip to content

Commit 14e3e0f

Browse files
committed
Use artifactoryUsername/Password
1 parent 76f33ae commit 14e3e0f

File tree

2 files changed

+34
-5
lines changed

2 files changed

+34
-5
lines changed

Jenkinsfile

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,20 @@ properties(projectProperties)
88
def SUCCESS = hudson.model.Result.SUCCESS.toString()
99
currentBuild.result = SUCCESS
1010

11+
12+
def ARTIFACTORY_CREDENTIALS = usernamePassword(credentialsId: '02bd1690-b54f-4c9f-819d-a77cb7a9822c', usernameVariable: 'ARTIFACTORY_USERNAME', passwordVariable: 'ARTIFACTORY_PASSWORD')
13+
1114
try {
1215
parallel check: {
1316
stage('Check') {
1417
node {
1518
checkout scm
1619
sh "git clean -dfx"
1720
try {
18-
withEnv(["JAVA_HOME=${ tool 'jdk8' }"]) {
19-
sh "./gradlew test --refresh-dependencies --no-daemon --stacktrace"
21+
withCredentials([ARTIFACTORY_CREDENTIALS]) {
22+
withEnv(["JAVA_HOME=${ tool 'jdk8' }"]) {
23+
sh "./gradlew test -PartifactoryUsername=$ARTIFACTORY_USERNAME -PartifactoryPassword=$ARTIFACTORY_PASSWORD --refresh-dependencies --no-daemon --stacktrace"
24+
}
2025
}
2126
} catch(Exception e) {
2227
currentBuild.result = 'FAILED: check'
@@ -37,7 +42,7 @@ try {
3742
withCredentials([file(credentialsId: 'spring-signing-secring.gpg', variable: 'SIGNING_KEYRING_FILE')]) {
3843
withCredentials([string(credentialsId: 'spring-gpg-passphrase', variable: 'SIGNING_PASSWORD')]) {
3944
withCredentials([usernamePassword(credentialsId: 'oss-token', passwordVariable: 'OSSRH_PASSWORD', usernameVariable: 'OSSRH_USERNAME')]) {
40-
withCredentials([usernamePassword(credentialsId: '02bd1690-b54f-4c9f-819d-a77cb7a9822c', usernameVariable: 'ARTIFACTORY_USERNAME', passwordVariable: 'ARTIFACTORY_PASSWORD')]) {
45+
withCredentials([ARTIFACTORY_CREDENTIALS]) {
4146
withEnv(["JAVA_HOME=${ tool 'jdk8' }"]) {
4247
sh "./gradlew deployArtifacts finalizeDeployArtifacts -Psigning.secretKeyRingFile=$SIGNING_KEYRING_FILE -Psigning.keyId=$SPRING_SIGNING_KEYID -Psigning.password='$SIGNING_PASSWORD' -PossrhUsername=$OSSRH_USERNAME -PossrhPassword=$OSSRH_PASSWORD -PartifactoryUsername=$ARTIFACTORY_USERNAME -PartifactoryPassword=$ARTIFACTORY_PASSWORD --refresh-dependencies --no-daemon --stacktrace"
4348
}

build.gradle

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
buildscript {
22
repositories {
3-
maven { url "https://repo.spring.io/plugins-release" }
4-
maven { url "https://repo.spring.io/plugins-snapshot" }
3+
maven {
4+
url = 'https://repo.spring.io/plugins-snapshot'
5+
if (project.hasProperty('artifactoryUsername')) {
6+
credentials {
7+
username "$artifactoryUsername"
8+
password "$artifactoryPassword"
9+
}
10+
}
11+
}
512
}
613
dependencies {
714
classpath "com.github.ben-manes:gradle-versions-plugin:0.17.0"
@@ -203,3 +210,20 @@ artifacts {
203210
archives project(':docs').docsZip
204211
archives project(':docs').schemaZip
205212
}
213+
214+
215+
if (project.hasProperty('artifactoryUsername')) {
216+
allprojects { project ->
217+
project.repositories { repos ->
218+
all { repo ->
219+
if (!repo.url.toString().startsWith("https://repo.spring.io/")) {
220+
return;
221+
}
222+
repo.credentials {
223+
username = artifactoryUsername
224+
password = artifactoryPassword
225+
}
226+
}
227+
}
228+
}
229+
}

0 commit comments

Comments
 (0)