@@ -140,43 +140,29 @@ public String getDefaultSauceConnectLogDirectory() {
140
140
private static final String SAUCE_CONNECT_PREFIX = "sauce-connect-" ;
141
141
public static final String SAUCE_CONNECT = SAUCE_CONNECT_PREFIX + CURRENT_SC_VERSION ;
142
142
143
- private static final int DEFAULT_API_PORT = 9000 ;
144
- private int apiPort ;
145
-
146
143
/** Constructs a new instance with quiet mode disabled. */
147
144
public SauceConnectManager () {
148
145
this (false );
149
146
}
150
147
151
- /**
152
- * Constructs a new instance with quiet mode disabled.
153
- *
154
- * @param runner System which runs SauceConnect, this info is added to '--metadata runner=' argument
155
- */
156
- public SauceConnectManager (String runner ) {
157
- this (false , runner , DEFAULT_API_PORT );
158
- }
159
-
160
148
/**
161
149
* Constructs a new instance.
162
150
*
163
151
* @param quietMode indicates whether Sauce Connect output should be suppressed
164
152
*/
165
153
public SauceConnectManager (boolean quietMode ) {
166
- this (quietMode , "jenkins" , DEFAULT_API_PORT );
154
+ this (quietMode , "jenkins" );
167
155
}
168
156
169
157
/**
170
158
* Constructs a new instance.
171
159
*
172
160
* @param quietMode indicates whether Sauce Connect output should be suppressed
173
161
* @param runner System which runs SauceConnect, this info is added to '--metadata runner=' argument
174
- * @param apiPort Port the Sauce Connect process will listen on
175
162
*/
176
- public SauceConnectManager (boolean quietMode , String runner , int apiPort ) {
163
+ public SauceConnectManager (boolean quietMode , String runner ) {
177
164
super (quietMode );
178
165
this .runner = runner ;
179
- this .apiPort = apiPort ;
180
166
}
181
167
182
168
/**
@@ -241,17 +227,13 @@ protected Process prepAndCreateProcess(
241
227
}
242
228
}
243
229
244
- if ( apiPort != 0 ) {
245
- this .apiPort = apiPort ;
246
- }
247
-
248
230
// although we are setting the working directory, we need to specify the full path to the exe
249
231
String [] args = {sauceConnectBinary .getPath ()};
250
232
if (legacy ) {
251
- args = generateSauceConnectArgsLegacy (args , username , accessKey , options );
233
+ args = generateSauceConnectArgsLegacy (args , username , accessKey , apiPort , options );
252
234
args = addExtraInfoLegacy (args );
253
235
} else {
254
- args = generateSauceConnectArgs (args , username , accessKey , options );
236
+ args = generateSauceConnectArgs (args , username , accessKey , apiPort , options );
255
237
args = addExtraInfo (args );
256
238
}
257
239
@@ -342,13 +324,14 @@ public static String getLatestSauceConnectVersion() {
342
324
* @param args the initial Sauce Connect command line args
343
325
* @param username name of the user which launched Sauce Connect
344
326
* @param accessKey the access key for the Sauce user
327
+ * @param apiPort specify the port the Sauce Connect API will listen on
345
328
* @param options command line args specified by the user
346
329
* @return String array representing the command line args to be used to launch Sauce Connect
347
330
*/
348
331
protected String [] generateSauceConnectArgs (
349
- String [] args , String username , String accessKey , String options ) {
332
+ String [] args , String username , String accessKey , int apiPort , String options ) {
350
333
String [] result =
351
- joinArgs (args , "run" , "--username" , username .trim (), "--access-key" , accessKey .trim (), "--api-address" , ":" + String .valueOf (this . apiPort ));
334
+ joinArgs (args , "run" , "--username" , username .trim (), "--access-key" , accessKey .trim (), "--api-address" , ":" + String .valueOf (apiPort ));
352
335
result = addElement (result , options );
353
336
return result ;
354
337
}
@@ -362,15 +345,16 @@ protected String[] addExtraInfo(String[] args) {
362
345
* @param args the initial Sauce Connect command line args
363
346
* @param username name of the user which launched Sauce Connect
364
347
* @param accessKey the access key for the Sauce user
348
+ * @param apiPort specify the port the Sauce Connect API will listen on
365
349
* @param options command line args specified by the user
366
350
* @return String array representing the command line args to be used to launch Sauce Connect
367
351
*/
368
352
@ Deprecated
369
353
protected String [] generateSauceConnectArgsLegacy (
370
- String [] args , String username , String accessKey , String options ) {
354
+ String [] args , String username , String accessKey , int apiPort , String options ) {
371
355
String [] result ;
372
356
373
- result = joinArgs (args , "legacy" , "--user" , username .trim (), "--api-key" , accessKey .trim (), "--status-address" , "0.0.0.0:" + String .valueOf (this . apiPort ));
357
+ result = joinArgs (args , "legacy" , "--user" , username .trim (), "--api-key" , accessKey .trim (), "--status-address" , "0.0.0.0:" + String .valueOf (apiPort ));
374
358
result = addElement (result , options );
375
359
return result ;
376
360
}
0 commit comments