Skip to content

Commit cff4b38

Browse files
authored
Fix detailed summary target url for maven and gradle (#530)
1 parent 1dff944 commit cff4b38

File tree

3 files changed

+19
-12
lines changed

3 files changed

+19
-12
lines changed

build-info-extractor-gradle/src/main/groovy/org/jfrog/gradle/plugin/artifactory/task/DeployTask.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ private void handleBuildInfoDeployment(ArtifactoryClientConfiguration accRoot, B
141141
}
142142
if (isGenerateDeployableArtifactsToFile(accRoot)) {
143143
try {
144-
exportDeployableArtifacts(allDeployDetails, new File(accRoot.info.getDeployableArtifactsFilePath()), accRoot.info.isBackwardCompatibleDeployableArtifacts());
144+
exportDeployableArtifacts(allDeployDetails, new File(accRoot.info.getDeployableArtifactsFilePath()), accRoot.info.isBackwardCompatibleDeployableArtifacts(), contextUrl);
145145
} catch (Exception e) {
146146
log.error("Failed writing deployable artifacts to file: ", e);
147147
throw new RuntimeException("Failed writing deployable artifacts to file", e);
@@ -235,9 +235,9 @@ private void exportBuildInfo(Build build, File toFile) throws IOException {
235235
BuildInfoExtractorUtils.saveBuildInfoToFile(build, toFile);
236236
}
237237

238-
private void exportDeployableArtifacts(Map<String, Set<DeployDetails>> allDeployDetails, File toFile, boolean exportBackwardCompatibleDeployableArtifacts) throws IOException {
238+
private void exportDeployableArtifacts(Map<String, Set<DeployDetails>> allDeployDetails, File toFile, boolean exportBackwardCompatibleDeployableArtifacts, String rtUrl) throws IOException {
239239
log.debug("Exporting deployable artifacts to '{}'", toFile.getAbsolutePath());
240-
DeployableArtifactsUtils.saveDeployableArtifactsToFile(allDeployDetails, toFile, exportBackwardCompatibleDeployableArtifacts);
240+
DeployableArtifactsUtils.saveDeployableArtifactsToFile(allDeployDetails, toFile, exportBackwardCompatibleDeployableArtifacts, rtUrl);
241241
}
242242

243243
private File getExportFile(ArtifactoryClientConfiguration clientConf) {

build-info-extractor-maven3/src/main/java/org/jfrog/build/extractor/maven/BuildDeploymentHelper.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ public void deploy( Build build,
8282

8383
if (!StringUtils.isEmpty(clientConf.info.getDeployableArtifactsFilePath())) {
8484
try {
85-
DeployableArtifactsUtils.saveDeployableArtifactsToFile(deployableArtifactsByModule, new File(clientConf.info.getDeployableArtifactsFilePath()), false);
85+
String rtUrl = clientConf.info.getProps().get("artifactory.publish.contextUrl");
86+
DeployableArtifactsUtils.saveDeployableArtifactsToFile(deployableArtifactsByModule, new File(clientConf.info.getDeployableArtifactsFilePath()), false, rtUrl);
8687
} catch (Exception e) {
8788
logger.error("Failed writing deployable artifacts to file: ", e);
8889
throw new RuntimeException("Failed writing deployable artifacts to file", e);

build-info-extractor/src/main/java/org/jfrog/build/extractor/clientConfiguration/deploy/DeployableArtifactsUtils.java

+14-8
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import com.fasterxml.jackson.core.type.TypeReference;
55
import com.fasterxml.jackson.databind.ObjectMapper;
66
import com.fasterxml.jackson.databind.exc.MismatchedInputException;
7+
import org.apache.commons.lang.StringUtils;
78
import org.jfrog.build.client.DeployableArtifactDetail;
89

910
import java.io.File;
@@ -19,18 +20,18 @@
1920
*/
2021
public class DeployableArtifactsUtils {
2122

22-
public static void saveDeployableArtifactsToFile(Map<String, Set<DeployDetails>> deployableArtifactsByModule, File toFile, boolean saveBackwardCompatible) throws IOException {
23+
public static void saveDeployableArtifactsToFile(Map<String, Set<DeployDetails>> deployableArtifactsByModule, File toFile, boolean saveBackwardCompatible, String rtUrl) throws IOException {
2324
if (saveBackwardCompatible) {
2425
saveBackwardCompatibleDeployableArtifacts(deployableArtifactsByModule, toFile);
2526
return;
2627
}
27-
saveDeployableArtifactsByModule(deployableArtifactsByModule, toFile);
28+
saveDeployableArtifactsByModule(deployableArtifactsByModule, toFile, rtUrl);
2829
}
2930

30-
private static void saveDeployableArtifactsByModule(Map<String, Set<DeployDetails>> deployableArtifactsByModule, File toFile) throws IOException {
31+
private static void saveDeployableArtifactsByModule(Map<String, Set<DeployDetails>> deployableArtifactsByModule, File toFile, String rtUrl) throws IOException {
3132
Map<String, List<DeployableArtifactDetail>> deployableArtifactsDetails = new HashMap<>();
3233
deployableArtifactsByModule.forEach((module, deployableArtifacts) ->
33-
deployableArtifactsDetails.put(module, DeployableArtifactsUtils.getDeployableArtifactsPaths(deployableArtifacts)));
34+
deployableArtifactsDetails.put(module, DeployableArtifactsUtils.getDeployableArtifactsPaths(deployableArtifacts, rtUrl)));
3435
ObjectMapper mapper = new ObjectMapper();
3536
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
3637
mapper.writeValue(toFile, deployableArtifactsDetails);
@@ -43,7 +44,7 @@ private static void saveDeployableArtifactsByModule(Map<String, Set<DeployDetail
4344
private static void saveBackwardCompatibleDeployableArtifacts(Map<String, Set<DeployDetails>> deployableArtifactsByModule, File toFile) throws IOException {
4445
List<DeployableArtifactDetail> deployableArtifactsList = new ArrayList<DeployableArtifactDetail>();
4546
deployableArtifactsByModule.forEach((module, deployableArtifacts) ->
46-
deployableArtifactsList.addAll(DeployableArtifactsUtils.getDeployableArtifactsPaths(deployableArtifacts)));
47+
deployableArtifactsList.addAll(DeployableArtifactsUtils.getDeployableArtifactsPaths(deployableArtifacts, "")));
4748
ObjectMapper mapper = new ObjectMapper();
4849
mapper.writeValue(toFile, deployableArtifactsList);
4950
}
@@ -83,10 +84,15 @@ private static Map<String, List<DeployableArtifactDetail>> loadBackwardCompatibl
8384
return deployableArtifactMap;
8485
}
8586

86-
private static List<DeployableArtifactDetail> getDeployableArtifactsPaths(Set<DeployDetails> deployDetails) {
87-
List<DeployableArtifactDetail> deployableArtifacts = new ArrayList<DeployableArtifactDetail>();
87+
private static List<DeployableArtifactDetail> getDeployableArtifactsPaths(Set<DeployDetails> deployDetails, String rtUrl) {
88+
List<DeployableArtifactDetail> deployableArtifacts = new ArrayList<>();
8889
for (DeployDetails artifact : deployDetails) {
89-
deployableArtifacts.add(new DeployableArtifactDetail(artifact.getFile().getAbsolutePath(), artifact.getArtifactPath(), artifact.getSha1(), artifact.getSha256(), artifact.getDeploySucceeded()));
90+
String artifactDest = artifact.getArtifactPath();
91+
// In case we want artifact absolute path in Artifactory - add rtUrl and repository to destination.
92+
if (StringUtils.isBlank(rtUrl)){
93+
artifactDest = rtUrl + artifact.getTargetRepository() + "/" + artifactDest;
94+
}
95+
deployableArtifacts.add(new DeployableArtifactDetail(artifact.getFile().getAbsolutePath(), artifactDest, artifact.getSha1(), artifact.getSha256(), artifact.getDeploySucceeded()));
9096
}
9197
return deployableArtifacts;
9298
}

0 commit comments

Comments
 (0)