Skip to content

Commit 5359398

Browse files
committed
2 parents 72f809a + 7282c0f commit 5359398

File tree

1 file changed

+27
-14
lines changed

1 file changed

+27
-14
lines changed

src/reportgenerator.ts

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,24 +45,37 @@ async function run() {
4545

4646
output = '';
4747
resultCode = 0;
48-
49-
try {
50-
resultCode = await exec.exec(
51-
'dotnet',
52-
['tool', 'install', 'dotnet-reportgenerator-globaltool', '--tool-path', toolpath, '--version', VERSION, '--ignore-failed-sources'],
53-
{
54-
listeners: {
55-
stdout: (data: Buffer) => {
56-
output += data.toString();
48+
49+
const maxRetries = 3;
50+
let attempt = 0;
51+
let success = false;
52+
53+
while (attempt < maxRetries && !success) {
54+
try {
55+
resultCode = await exec.exec(
56+
'dotnet',
57+
['tool', 'install', 'dotnet-reportgenerator-globaltool', '--tool-path', toolpath, '--version', VERSION, '--ignore-failed-sources'],
58+
{
59+
listeners: {
60+
stdout: (data: Buffer) => {
61+
output += data.toString();
62+
}
5763
}
5864
}
65+
);
66+
success = true;
67+
} catch (error) {
68+
attempt++;
69+
core.info(`Attempt ${attempt} to install ReportGenerator failed.`);
70+
if (attempt >= maxRetries) {
71+
core.setFailed("Failed to install ReportGenerator global tool after multiple attempts");
72+
return;
5973
}
60-
);
61-
} catch (error) {
62-
core.setFailed("Failed to install ReportGenerator global tool");
63-
return;
74+
core.info("Retrying in 10 seconds...");
75+
await new Promise(resolve => setTimeout(resolve, 10000));
76+
}
6477
}
65-
78+
6679
core.info("Successfully installed ReportGenerator global tool");
6780
}
6881

0 commit comments

Comments
 (0)