Skip to content

Commit fc393df

Browse files
authored
Merge pull request #71 from jenkinsci/Release_7.5.0-3
Enhancement - update 7.5.0-9
2 parents e122952 + 866c384 commit fc393df

File tree

5 files changed

+59
-21
lines changed

5 files changed

+59
-21
lines changed

README.md

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,35 +66,41 @@ DAI suite name for the specified test configuration. (Use this argument if only
6666
Alternatively, you could set a repo secret in `Repo Settings > Secrets > Actions` and refer to it like below:<br />
6767
`clientSecret: "${{ secrets.DAI_CLIENT_SECRET }}"`.
6868

69-
The **DAI Client Secret** can be obtain by go to `http(s):/dai_server_hostname:portnumber/ > System > API Access > Add New` (for new API access creation)
69+
The **DAI Client Secret** can be obtain by go to `http(s):/dai_server_hostname:portnumber/ > System > API Access > Add New`. (for new API access creation)
7070

7171
![image](https://user-images.githubusercontent.com/101400930/206938890-07a45761-3c49-40a7-bf48-1a1b6f3b3659.png)
7272

7373
### `requestTimeout`
74-
**[Optional]** The timeout in seconds for each HTTP request to the Eggplant DAI server<br />
74+
**[Optional]** The timeout in seconds for each HTTP request to the Eggplant DAI server.<br />
7575
**Default:** `30`
7676

7777
### `requestRetries`
78-
**[Optional]** The number of times to attempt each HTTP request to the Eggplant DAI server<br />
78+
**[Optional]** The number of times to attempt each HTTP request to the Eggplant DAI server.<br />
7979
**Default:** `5`
8080

8181
### `backoffFactor`
82-
**[Optional]** The exponential backoff factor between each HTTP request<br />
82+
**[Optional]** The exponential backoff factor between each HTTP request.<br />
8383
**Default:** `0.5`
8484

8585
### `logLevel`
86-
**[Optional]** The logging level<br />
86+
**[Optional]** The logging level.<br />
8787
**Default:** `INFO`
8888

8989
### `CACertPath`
90-
**[Optional]** The path to an alternative Certificate Authority pem file<br />
90+
**[Optional]** The path to an alternative Certificate Authority pem file.<br />
9191

9292
### `testResultPath`
93-
**[Optional]** Path to a file where the test results will be stored in junit xml format<br />
93+
**[Optional]** The path to a file where the test results will be stored in JUnit XML format.<br />
9494
**Example** `C:\results\result.xml`
9595

9696
### `eggplantRunnerPath`
97-
**[Optional]** The path to eggplant runner CLI executable<br />
97+
**[Optional]** The path to Eggplant runner CLI executable.<br />
98+
99+
### `parameters`
100+
**[Optional]** The global parameter(s) to override in the format `parameter_name=parameter_value`.<br />
101+
**Example** `username=Lily`<br />
102+
You can override multiple parameters by separating them with a two semi-colon delimeter (`;;`).<br />
103+
**Example** `username=Lily;;city=Paris;;hobby=Jogging`
98104

99105
## Output
100106

@@ -148,6 +154,7 @@ pipeline {
148154
Output are shown in **Console Output**
149155
![image](https://user-images.githubusercontent.com/101400930/169546010-1fce3d53-daa2-42e4-8945-0f6f49870d5d.png)
150156

157+
**NEW for DAI 7.5:** for pipeline porject in Mac, if parameters input having quotes `"`, they need to be escaped.
151158
## Release for DAI
152159
<table>
153160
<thead>
@@ -157,9 +164,13 @@ Output are shown in **Console Output**
157164
</tr>
158165
</thead>
159166
<tbody>
167+
<tr>
168+
<td>7.5.0-9</td>
169+
<td><a href="https://plugins.jenkins.io/eggplant-runner/">latest</td>
170+
</tr>
160171
<tr>
161172
<td>7.4.0-4</td>
162-
<td><a href="https://plugins.jenkins.io/eggplant-runner/">latest</a> (with cve fix)<br /><a href="https://plugins.jenkins.io/eggplant-runner/"><a href="https://updates.jenkins.io/download/plugins/eggplant-runner/0.0.1.265.v56273b_eece56/eggplant-runner.hpi"> 0.0.1.270.vcb_9192a_2c004 </a>(works with 7.4.0-4)</td>
173+
<td><a href="https://plugins.jenkins.io/eggplant-runner/"><a href="https://updates.jenkins.io/download/plugins/eggplant-runner/0.0.1.274.ve12295250d73/eggplant-runner.hpi"> 0.0.1.274.ve12295250d73 </a> (with cve fix)<br /><a href="https://plugins.jenkins.io/eggplant-runner/"><a href="https://updates.jenkins.io/download/plugins/eggplant-runner/0.0.1.270.vcb_9192a_2c004/eggplant-runner.hpi"> 0.0.1.270.vcb_9192a_2c004 </a>(works with 7.4.0-4)</td>
163174
</tr>
164175
<tr>
165176
<td>7.3.0-3</td>

src/main/java/io/jenkins/plugins/eggplant/EggplantRunnerBuilder.java

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ public class EggplantRunnerBuilder extends Builder implements SimpleBuildStep {
5858
private Boolean dryRun;
5959
private String eggplantRunnerPath;
6060
private TestConfig testConfig;
61+
private String parameters;
6162

6263
@DataBoundConstructor
6364
public EggplantRunnerBuilder() {
@@ -105,6 +106,9 @@ public String getBackoffFactor() {
105106
public String getEggplantRunnerPath() {
106107
return eggplantRunnerPath;
107108
}
109+
public String getParameters() {
110+
return parameters;
111+
}
108112

109113
public TestConfig getTestConfig() {
110114
if(this.testConfigId != null)
@@ -197,6 +201,10 @@ public void setTestConfig(TestConfig testConfig) {
197201
this.testConfig = testConfig;
198202
}
199203

204+
@DataBoundSetter
205+
public void setParameters(String parameters) {
206+
this.parameters = parameters;
207+
}
200208

201209
@Override
202210
public void perform(Run<?, ?> run, FilePath workspace, EnvVars env, Launcher launcher, TaskListener listener) throws InterruptedException, IOException {
@@ -228,7 +236,7 @@ public void perform(Run<?, ?> run, FilePath workspace, EnvVars env, Launcher lau
228236
CLIRunnerHelper.downloadRunner(env.get("gitlabAccessToken"));
229237

230238
FilePath cliRunnerPath = CLIRunnerHelper.getFilePath();
231-
String[] command = this.getCommand(cliRunnerPath, env);
239+
String[] command = this.getCommand(cliRunnerPath, env, os);
232240
logger.println("command: " + Arrays.toString(command));
233241

234242
cliRunnerPath.chmod(0755);
@@ -357,7 +365,7 @@ else if (env.get("DAI_CLIENT_SECRET") != null && !env.get("DAI_CLIENT_SECRET").e
357365
return args;
358366
}
359367

360-
public List<String> getOptionalCommandList(){
368+
public List<String> getOptionalCommandList(OperatingSystem os){
361369
List<String> args = new ArrayList<String>();
362370
if (this.logLevel != null) // logLevelArg
363371
args.add(String.format("--log-level=%s", this.logLevel));
@@ -373,16 +381,27 @@ public List<String> getOptionalCommandList(){
373381
args.add("--dry-run");
374382
if (this.backoffFactor != null && !this.backoffFactor.equals("")) // backoffFactorArg
375383
args.add(String.format("--backoff-factor=%s", this.backoffFactor));
384+
if (this.parameters != null && !this.parameters.equals("")) { // parameters
385+
String[] values = this.parameters.split(";;");
386+
for (String value : values) {
387+
args.add("--param");
388+
if (os == OperatingSystem.LINUX || os == OperatingSystem.MACOS || !value.contains(" ")) {
389+
args.add(value);
390+
} else {
391+
args.add(value.replace("\"", "\\\""));
392+
}
393+
}
394+
}
376395
return args;
377396
}
378397

379-
private String[] getCommand(FilePath cliFile, EnvVars env) throws BuilderException {
398+
private String[] getCommand(FilePath cliFile, EnvVars env, OperatingSystem os) throws BuilderException {
380399
List<String> commandList = new ArrayList<String>();
381400
//commandList.add("./" + cliFile.getName()); // cliRunnerPath
382401
commandList.add(cliFile.getRemote()); // cliRunnerPath
383402
this.getBackwardCompatibilityCommands();
384403
commandList.addAll(getMandatoryCommandList(env));
385-
commandList.addAll(getOptionalCommandList());
404+
commandList.addAll(getOptionalCommandList(os));
386405
return commandList.toArray(new String[0]);
387406
}
388407

src/main/java/io/jenkins/plugins/eggplant/utils/CLIRunnerHelper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
public class CLIRunnerHelper{
2727

28-
private final static String CLI_VERSION = "7.4.0-4";
28+
private final static String CLI_VERSION = "7.5.0-9";
2929
private final static Map<OperatingSystem, String> CLI_FILENAME = Stream.of(
3030
new AbstractMap.SimpleEntry<>(OperatingSystem.LINUX, "eggplant-runner-Linux-${cliVersion}"),
3131
new AbstractMap.SimpleEntry<>(OperatingSystem.MACOS, "eggplant-runner-MacOS-${cliVersion}"),

src/main/resources/io/jenkins/plugins/eggplant/EggplantRunnerBuilder/config.jelly

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,5 +89,12 @@
8989
The path to eggplant runner CLI executable
9090
<br><strong>E.g.</strong> <em> C:\eggplant\eggplant-runner-Windows-x.x.x-x.exe </em></br>
9191
</f:entry>
92+
<f:entry title="Parameters " field="parameters">
93+
<f:textbox />
94+
The global parameter(s) to override in the format <code>parameter_name=parameter_value</code>
95+
<br><strong>E.g.</strong> <code>username=Lily</code> </br>
96+
<br>You can override multiple parameters by separating them with a two semi-colon delimeter (<code>;;</code>).</br>
97+
<br><strong>E.g.</strong> <code>username=Lily;;city=Paris;;hobby=Jogging</code> </br>
98+
</f:entry>
9299
</f:advanced>
93100
</j:jelly>

src/test/java/io/jenkins/plugins/eggplant/EggplantRunnerBuilderTest.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import io.jenkins.plugins.eggplant.EggplantRunnerBuilder.ScriptBased;
2222
import io.jenkins.plugins.eggplant.EggplantRunnerBuilder.TestConfigId;
2323
import io.jenkins.plugins.eggplant.common.LogLevel;
24+
import io.jenkins.plugins.eggplant.common.OperatingSystem;
2425
import io.jenkins.plugins.eggplant.exception.BuilderException;
2526

2627
public class EggplantRunnerBuilderTest {
@@ -199,31 +200,31 @@ public void testOptionalCommandList(){
199200
List<String> command = new ArrayList<String>();
200201

201202
builder.setLogLevel(LogLevel.WARNING);
202-
command = builder.getOptionalCommandList();
203+
command = builder.getOptionalCommandList(OperatingSystem.WINDOWS);
203204
assertTrue(command.contains("--log-level=WARNING"));
204205

205206
builder.setCACertPath("cert path");
206-
command = builder.getOptionalCommandList();
207+
command = builder.getOptionalCommandList(OperatingSystem.WINDOWS);
207208
assertTrue(command.contains("--ca-cert-path=cert path"));
208209

209210
builder.setTestResultPath("result path");
210-
command = builder.getOptionalCommandList();
211+
command = builder.getOptionalCommandList(OperatingSystem.WINDOWS);
211212
assertTrue(command.contains("--test-result-path=result path"));
212213

213214
builder.setRequestTimeout("5");
214-
command = builder.getOptionalCommandList();
215+
command = builder.getOptionalCommandList(OperatingSystem.WINDOWS);
215216
assertTrue(command.contains("--request-timeout=5"));
216217

217218
builder.setRequestRetries("5");
218-
command = builder.getOptionalCommandList();
219+
command = builder.getOptionalCommandList(OperatingSystem.WINDOWS);
219220
assertTrue(command.contains("--request-retries=5"));
220221

221222
builder.setBackoffFactor("5");
222-
command = builder.getOptionalCommandList();
223+
command = builder.getOptionalCommandList(OperatingSystem.WINDOWS);
223224
assertTrue(command.contains("--backoff-factor=5"));
224225

225226
builder.setDryRun(true);
226-
command = builder.getOptionalCommandList();
227+
command = builder.getOptionalCommandList(OperatingSystem.WINDOWS);
227228
assertTrue(command.contains("--dry-run"));
228229

229230
}

0 commit comments

Comments
 (0)