Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[JENKINS-34437] Factory to use Jenkins Proxy configuration with a Ama…
…zonECRClient. (#10)

* Factory to use Jenkins Proxy configuration with a AmazonECRClient.

* minimise class
  • Loading branch information
kuisathaverat authored and Vlatombe committed Mar 27, 2017
1 parent 8ec69b4 commit 76824ef
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/main/java/com/amazonaws/AmazonECRClientFactory.java
@@ -0,0 +1,29 @@
package com.amazonaws;

import com.amazonaws.auth.AWSCredentials;
import com.amazonaws.services.ecr.AmazonECRClient;
import jenkins.model.Jenkins;

/**
* Factory to use Jenkins Proxy configuration with a AmazonECRClient.
*
* @author Marcus Wallin, kuisathaverat
*/
public class AmazonECRClientFactory {

/**
* @param credentials {@link AWSCredentials} to use.
* @return {@link AmazonECRClient} configured to use the proxy configured on Jenkins.
*/
public AmazonECRClient getAmazonECRClientWithProxy(AWSCredentials credentials) {
ClientConfiguration conf = new ClientConfiguration();
Jenkins j = Jenkins.getInstance();
if (j != null && j.proxy != null) {
conf.setProxyHost(j.proxy.name);
conf.setProxyPort(j.proxy.port);
conf.setProxyUsername(j.proxy.getUserName());
conf.setProxyPassword(j.proxy.getPassword());
}
return new AmazonECRClient(credentials, conf);
}
}

0 comments on commit 76824ef

Please sign in to comment.