Skip to content

Commit 6a5550d

Browse files
committed
Add retries around flaky sonatype central upload.
1 parent da8169b commit 6a5550d

File tree

2 files changed

+28
-15
lines changed

2 files changed

+28
-15
lines changed

contrib/sonatypecentral/src/mill/contrib/sonatypecentral/SonatypeCentralPublisher.scala

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,16 +87,23 @@ class SonatypeCentralPublisher(
8787
publishingType: PublishingType
8888
): Unit = {
8989
try {
90-
sonatypeCentralClient.uploadBundleFromFile(
91-
zipFile,
92-
deploymentName,
93-
Some(publishingType),
94-
timeout = awaitTimeout
95-
)
90+
mill.api.Retry(
91+
count = 5,
92+
backoffMillis = 1000,
93+
filter = (_, ex) => ex.getMessage.contains("Read end dead")
94+
) {
95+
sonatypeCentralClient.uploadBundleFromFile(
96+
zipFile,
97+
deploymentName,
98+
Some(publishingType),
99+
timeout = awaitTimeout
100+
)
101+
}
96102
} catch {
97103
case ex: Throwable => {
98104
throw new RuntimeException(
99-
s"Failed to publish ${deploymentName.unapply} to Sonatype Central. Error: \n${ex.getMessage}"
105+
s"Failed to publish ${deploymentName.unapply} to Sonatype Central",
106+
ex
100107
)
101108
}
102109

scalalib/src/mill/scalalib/SonatypeCentralPublisher.scala

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,19 +87,25 @@ class SonatypeCentralPublisher(
8787
publishingType: PublishingType
8888
): Unit = {
8989
try {
90-
sonatypeCentralClient.uploadBundleFromFile(
91-
zipFile,
92-
deploymentName,
93-
Some(publishingType),
94-
timeout = awaitTimeout
95-
)
90+
mill.api.Retry(
91+
count = 5,
92+
backoffMillis = 1000,
93+
filter = (_, ex) => ex.getMessage.contains("Read end dead")
94+
) {
95+
sonatypeCentralClient.uploadBundleFromFile(
96+
zipFile,
97+
deploymentName,
98+
Some(publishingType),
99+
timeout = awaitTimeout
100+
)
101+
}
96102
} catch {
97103
case ex: Throwable => {
98104
throw new RuntimeException(
99-
s"Failed to publish ${deploymentName.unapply} to Sonatype Central. Error: \n${ex.getMessage}"
105+
s"Failed to publish ${deploymentName.unapply} to Sonatype Central",
106+
ex
100107
)
101108
}
102-
103109
}
104110

105111
log.info(s"Successfully published ${deploymentName.unapply} to Sonatype Central")

0 commit comments

Comments
 (0)