Authenticate when pulling io.spring.docresources:spring-doc-resources from Arifactory repo.spring.io/release repository.
This commit is contained in:
14
Jenkinsfile
vendored
14
Jenkinsfile
vendored
@@ -64,12 +64,14 @@ pipeline {
|
||||
script {
|
||||
docker.image(p['docker.container.image.java.main']).inside(p['docker.container.inside.env.basic']) {
|
||||
withCredentials([file(credentialsId: 'docs.spring.io-jenkins_private_ssh_key', variable: 'DEPLOY_SSH_KEY')]) {
|
||||
try {
|
||||
sh "ci/deployDocs.sh"
|
||||
}
|
||||
catch (e) {
|
||||
currentBuild.result = "FAILED: deploy docs"
|
||||
throw e
|
||||
withCredentials([usernamePassword(credentialsId: p['artifactory.credentials'], usernameVariable: 'ARTIFACTORY_USERNAME', passwordVariable: 'ARTIFACTORY_PASSWORD')]) {
|
||||
try {
|
||||
sh "ci/deployDocs.sh"
|
||||
}
|
||||
catch (e) {
|
||||
currentBuild.result = "FAILED: deploy docs"
|
||||
throw e
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,11 +121,41 @@ public class AsciidoctorConventionPlugin implements Plugin<Project> {
|
||||
|
||||
if (repositories.isEmpty()) {
|
||||
repositories.mavenCentral();
|
||||
repositories.maven(repo -> repo.setUrl(URI.create("https://repo.spring.io/release")));
|
||||
repositories.maven(repo -> {
|
||||
repo.credentials(passwordCredentials -> {
|
||||
passwordCredentials.setUsername(resolveArtifactoryUsername(project));
|
||||
passwordCredentials.setPassword(resolveArtifactoryPassword(project));
|
||||
});
|
||||
repo.setUrl(URI.create("https://repo.spring.io/release"));
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private boolean isCredentialSet(Object target) {
|
||||
return target != null && !String.valueOf(target).trim().isEmpty();
|
||||
}
|
||||
|
||||
private String resolveArtifactoryPassword(Project project) {
|
||||
|
||||
Object artifactoryPassword = project.getProperties().get("artifactoryPassword");
|
||||
|
||||
artifactoryPassword = isCredentialSet(artifactoryPassword) ? artifactoryPassword
|
||||
: System.getenv().get("ARTIFACTORY_PASSWORD");
|
||||
|
||||
return String.valueOf(artifactoryPassword);
|
||||
}
|
||||
|
||||
private String resolveArtifactoryUsername(Project project) {
|
||||
|
||||
Object artifactoryUsername = project.getProperties().get("artifactoryUsername");
|
||||
|
||||
artifactoryUsername = isCredentialSet(artifactoryUsername) ? artifactoryUsername
|
||||
: System.getenv().get("ARTIFACTORY_USERNAME");
|
||||
|
||||
return String.valueOf(artifactoryUsername);
|
||||
}
|
||||
|
||||
/**
|
||||
* Requests the base Spring Documentation Resources from {@literal https://repo.spring.io/release} and uses it
|
||||
* to format and render documentation.
|
||||
|
||||
Reference in New Issue
Block a user