Skip to content

Commit fdc760d

Browse files
committed
Consistently check for network settings file and mapping file
1 parent 699485e commit fdc760d

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

components/fetch-build-scan-data-cmdline-tool/src/main/java/com/gradle/enterprise/model/CustomValueNames.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,18 @@ public class CustomValueNames {
1212
);
1313

1414
public static CustomValueNames loadFromFile(Path customValueMappingFile) throws IOException {
15-
try (BufferedReader in = Files.newBufferedReader(customValueMappingFile)) {
16-
Properties mappingProps = new Properties();
17-
mappingProps.load(in);
18-
return new CustomValueNames(
19-
mappingProps.getProperty("git.repository", DEFAULT.getGitRepositoryKey()),
20-
mappingProps.getProperty("git.branch", DEFAULT.getGitBranchKey()),
21-
mappingProps.getProperty("git.commitId", DEFAULT.getGitCommitIdKey())
22-
);
15+
if (Files.isRegularFile(customValueMappingFile)) {
16+
try (BufferedReader in = Files.newBufferedReader(customValueMappingFile)) {
17+
Properties mappingProps = new Properties();
18+
mappingProps.load(in);
19+
return new CustomValueNames(
20+
mappingProps.getProperty("git.repository", DEFAULT.getGitRepositoryKey()),
21+
mappingProps.getProperty("git.branch", DEFAULT.getGitBranchKey()),
22+
mappingProps.getProperty("git.commitId", DEFAULT.getGitCommitIdKey())
23+
);
24+
}
2325
}
26+
return CustomValueNames.DEFAULT;
2427
}
2528

2629
private final String gitRepositoryKey;

components/scripts/lib/build_scan.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,9 @@ fetch_and_read_build_scan_data() {
166166
args+=("--mapping-file" "${mapping_file}")
167167
fi
168168

169-
args+=("--network-settings-file" "${SCRIPT_DIR}/network.settings")
169+
if [ -f "${SCRIPT_DIR}/network.settings" ]; then
170+
args+=("--network-settings-file" "${SCRIPT_DIR}/network.settings")
171+
fi
170172

171173
if [[ "$1" == "build_cache_metrics_only" ]]; then
172174
build_cache_metrics_only="true"

0 commit comments

Comments
 (0)