Skip to content
Browse files
[JENKINS-51402] Presigned url has the wrong region (#29)
Presigned url has the wrong region when running from a different one
  • Loading branch information
kuisathaverat authored and carlossg committed May 24, 2018
1 parent 3e8b770 commit 333330c5cfbad0ff4e421f7e19db6ca13d6bbfcf
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
@@ -128,3 +128,9 @@ docker run --rm -i --init -v <YOUR_HOME_DIR>/.aws:/home/jenkins/.aws -e AWS_REGI

but note that the mount will not work if your `~/.aws/` is set to be readable only by the user.

# Force the Region

If you have problems detecting the region on your environment you can force the region setting by adding this property
`-Dio.jenkins.plugins.artifact_manager_s3.S3BlobStore.region=REGION_NAME` to the Jenkins JVM options.
@@ -34,18 +34,23 @@
import java.util.Date;
import java.util.NoSuchElementException;
import java.util.Properties;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import java.util.logging.Logger;

import javax.annotation.Nonnull;

import io.jenkins.plugins.artifact_manager_jclouds.JCloudsArtifactManager;
import org.apache.commons.lang.StringUtils;
import org.jclouds.ContextBuilder;
import org.jclouds.blobstore.BlobStoreContext;
import org.jclouds.blobstore.domain.Blob;
import org.jclouds.domain.Credentials;
import org.jclouds.location.reference.LocationConstants;
import org.jclouds.osgi.ProviderRegistry;
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.NoExternalUse;
@@ -75,6 +80,8 @@ public class S3BlobStore extends BlobStoreProvider {
private static String BLOB_CONTAINER = System.getenv("S3_BUCKET");
private static String PREFIX = System.getenv("S3_DIR");
private static String REGION = System.getProperty(S3BlobStore.class.getName() + ".region");

public S3BlobStore() {}
@@ -94,6 +101,12 @@ public BlobStoreContext getContext() throws IOException {
LOGGER.log(Level.FINEST, "Building context");
try {
Properties props = new Properties();

if(StringUtils.isNotBlank(REGION)) {
props.setProperty(LocationConstants.PROPERTY_REGIONS, REGION);

return ContextBuilder.newBuilder("aws-s3").credentialsSupplier(getCredentialsSupplier())
} catch (NoSuchElementException x) {

0 comments on commit 333330c

Please sign in to comment.