-
Notifications
You must be signed in to change notification settings - Fork 55
Proxy support for browserstack plugin #28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
francisf
merged 18 commits into
jenkinsci:master
from
harshitvasu:ACE-1568-proxy-apache-diverge
Nov 11, 2020
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
e1c10de
bare minimum without client changes
df57025
before testing
57b23bd
Working with proxy set 9:29 4 Nov, client needs no proxy setting and …
53afae7
sending all details to the client
b29623b
removed redundant changes
7c1d9a0
removed redundant changes
869b2b2
removed redundant changes
f172efe
pom file changes
a37c18e
pom file changes to resolve httpcomponents dependency error
8af6936
Added system property support for proxy
6d717b6
bump up the version of automate-client-java
30e85a1
Changes after review
caf57c3
change in formatting
d16ec50
formatting changes
062303a
change variable types
2b3b017
change variable types
f9263ec
version bump in integration plugin
58ab632
version bump in integration plugin
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
src/main/java/com/browserstack/automate/ci/common/proxysettings/JenkinsProxySettings.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package com.browserstack.automate.ci.common.proxysettings; | ||
|
||
import hudson.ProxyConfiguration; | ||
import jenkins.model.Jenkins; | ||
|
||
import java.net.InetSocketAddress; | ||
import java.net.Proxy; | ||
|
||
public class JenkinsProxySettings { | ||
|
||
private static final ProxyConfiguration jenkinsProxy = Jenkins.getInstanceOrNull() != null ? Jenkins.getInstanceOrNull().proxy : null; | ||
private static final String protocol = "https"; | ||
private static final String systemProxyHost = System.getProperty(protocol + ".proxyHost"); | ||
private static final int systemProxyPort = Integer.parseInt(System.getProperty(protocol + ".proxyPort", "0")); | ||
private static final String systemProxyUser = System.getProperty(protocol + ".proxyUser"); | ||
private static final String systemProxyPassword = System.getProperty(protocol + ".proxyPassword"); | ||
|
||
public static Proxy getJenkinsProxy() { | ||
if (hasSystemProxy()) { | ||
return new Proxy(Proxy.Type.HTTP, new InetSocketAddress(systemProxyHost, systemProxyPort)); | ||
} | ||
|
||
if (jenkinsProxy == null) return null; | ||
final String proxyHost = jenkinsProxy.name; | ||
final int proxyPort = jenkinsProxy.port; | ||
return (proxyHost != null && proxyPort != 0) ? new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxyHost, proxyPort)) : null; | ||
} | ||
|
||
public static String getHost() { | ||
if (hasSystemProxy()) { | ||
return systemProxyHost; | ||
} | ||
|
||
if (jenkinsProxy == null) return null; | ||
return jenkinsProxy.name; | ||
} | ||
|
||
public static int getPort() { | ||
if (hasSystemProxy()) { | ||
return systemProxyPort; | ||
} | ||
|
||
if (jenkinsProxy == null) return 0; | ||
return jenkinsProxy.port; | ||
} | ||
|
||
public static String getUsername() { | ||
if (hasSystemProxy() && systemProxyUser != null && systemProxyPassword != null) { | ||
return systemProxyUser; | ||
} | ||
|
||
if (jenkinsProxy == null) return null; | ||
return jenkinsProxy.getUserName(); | ||
} | ||
|
||
public static String getPassword() { | ||
if (hasSystemProxy() && systemProxyUser != null && systemProxyPassword != null) { | ||
return systemProxyPassword; | ||
} | ||
|
||
if (jenkinsProxy == null) return null; | ||
return jenkinsProxy.getPassword(); | ||
} | ||
|
||
public static ProxyConfiguration getProxyConfig() { | ||
return jenkinsProxy; | ||
} | ||
|
||
public static boolean hasProxy() { | ||
return getHost() != null && getPort() != 0; | ||
} | ||
|
||
public static boolean hasSystemProxy() { | ||
return systemProxyHost != null && systemProxyPort != 0; | ||
} | ||
|
||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 17 additions & 12 deletions
29
src/main/java/com/browserstack/automate/ci/common/uploader/AppUploader.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,30 @@ | ||
package com.browserstack.automate.ci.common.uploader; | ||
|
||
import java.io.FileNotFoundException; | ||
|
||
import com.browserstack.appautomate.AppAutomateClient; | ||
import com.browserstack.automate.ci.common.proxysettings.JenkinsProxySettings; | ||
import com.browserstack.automate.ci.jenkins.BrowserStackCredentials; | ||
import com.browserstack.automate.exception.AppAutomateException; | ||
import com.browserstack.automate.exception.InvalidFileExtensionException; | ||
|
||
public class AppUploader { | ||
|
||
String appPath; | ||
BrowserStackCredentials credentials; | ||
String appPath; | ||
BrowserStackCredentials credentials; | ||
|
||
public AppUploader(String appPath, BrowserStackCredentials credentials) { | ||
this.appPath = appPath; | ||
this.credentials = credentials; | ||
} | ||
public AppUploader(String appPath, BrowserStackCredentials credentials) { | ||
this.appPath = appPath; | ||
this.credentials = credentials; | ||
} | ||
|
||
public String uploadFile() | ||
throws AppAutomateException, FileNotFoundException, InvalidFileExtensionException { | ||
AppAutomateClient appAutomateClient = | ||
new AppAutomateClient(credentials.getUsername(), credentials.getDecryptedAccesskey()); | ||
return appAutomateClient.uploadApp(this.appPath).getAppUrl(); | ||
} | ||
public String uploadFile() | ||
throws AppAutomateException, FileNotFoundException, InvalidFileExtensionException { | ||
AppAutomateClient appAutomateClient = | ||
new AppAutomateClient(credentials.getUsername(), credentials.getDecryptedAccesskey()); | ||
if (JenkinsProxySettings.hasProxy()) { | ||
appAutomateClient.setProxy(JenkinsProxySettings.getHost(), JenkinsProxySettings.getPort(), JenkinsProxySettings.getUsername(), JenkinsProxySettings.getPassword()); | ||
} | ||
return appAutomateClient.uploadApp(this.appPath).getAppUrl(); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.