Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@

# Maven #
/target/

# Intellij IDEA #
.idea/
*.iml
38 changes: 36 additions & 2 deletions src/main/java/de/jutzig/github/release/plugin/UploadMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,20 @@ public class UploadMojo extends AbstractMojo implements Contextualizable{
*/
private Boolean prerelease;

/**
* Number of attempts to upload, defaults to 5.
*
* @parameter default-value=5
*/
private int retryUploadCount = 5;

/**
* Retry timeout between failing uploads, defaults to 10 seconds.
*
* @parameter default-value=10000
*/
private int retryUploadTimeout = 10000;

public void execute() throws MojoExecutionException {
if(releaseName==null)
releaseName = tag;
Expand Down Expand Up @@ -214,8 +228,28 @@ private void uploadAsset(GHRelease release, File asset) throws IOException {
}

getLog().info(" Upload asset");
// for some reason this doesn't work currently
release.uploadAsset(asset, "application/zip");
int attempt = 0;
do {
try {
release.uploadAsset(asset, "application/zip");
break;
} catch (IOException e) {
if (attempt < retryUploadCount) {
getLog().warn(String.format("Asset %s failed to upload, retrying in %d seconds (%d/%d)."
, asset.getName()
, retryUploadTimeout / 1000
, attempt + 1
, retryUploadCount));
try {
Thread.sleep(retryUploadTimeout);
} catch (InterruptedException e1) {
throw new IOException(e1);
}
} else {
throw e;
}
}
} while (attempt++ <= retryUploadTimeout);
}

private void uploadAssets(GHRelease release, FileSet fileset) throws IOException {
Expand Down