-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ORCH-487 Add support for downloading artifacts without repox
- Loading branch information
1 parent
79672c9
commit fc4955b
Showing
14 changed files
with
934 additions
and
134 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
sonar-orchestrator/src/main/java/com/sonar/orchestrator/locator/ArtifactoryFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* Orchestrator | ||
* Copyright (C) 2011-2024 SonarSource SA | ||
* mailto:info AT sonarsource DOT com | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 3 of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
*/ | ||
package com.sonar.orchestrator.locator; | ||
|
||
import com.sonar.orchestrator.config.Configuration; | ||
import java.io.File; | ||
|
||
import static com.sonar.orchestrator.util.OrchestratorUtils.defaultIfEmpty; | ||
|
||
public class ArtifactoryFactory { | ||
|
||
private static final String DEFAULT_ARTIFACTORY_URL = "https://repox.jfrog.io/repox"; | ||
|
||
/** | ||
* Two types of Artifactory are supported: Maven and Default. | ||
* | ||
* <p> | ||
* Default repox artifactory is used if orchestrator.artifactory.url is empty or specifically set to <a href="https://repox.jfrog.io/repox">repox</a>. | ||
* Otherwise, we assume the URL points to a maven repository. | ||
* </p> | ||
*/ | ||
public static Artifactory createArtifactory(Configuration configuration) { | ||
File downloadTempDir = new File(configuration.fileSystem().workspace(), "temp-downloads"); | ||
String baseUrl = defaultIfEmpty(configuration.getStringByKeys("orchestrator.artifactory.url", "ARTIFACTORY_URL"), DEFAULT_ARTIFACTORY_URL); | ||
|
||
if (baseUrl.startsWith(DEFAULT_ARTIFACTORY_URL)) { | ||
String accessToken = configuration.getStringByKeys("orchestrator.artifactory.accessToken", "ARTIFACTORY_ACCESS_TOKEN"); | ||
String apiKey = configuration.getStringByKeys("orchestrator.artifactory.apiKey", "ARTIFACTORY_API_KEY"); | ||
return new DefaultArtifactory(downloadTempDir, baseUrl, accessToken, apiKey); | ||
} else { | ||
return new MavenArtifactory(downloadTempDir, baseUrl); | ||
} | ||
} | ||
|
||
private ArtifactoryFactory() { | ||
} | ||
|
||
} |
Oops, something went wrong.