Permalink
Browse files

[FIXED JENKINS-13559] Allow passing extra command line parameters to …

…monkey.
  • Loading branch information...
orrc committed Mar 12, 2015
1 parent 5709bc2 commit a8158e40dab6247dd27c7e483aa1b19e983c99e7
@@ -28,6 +28,7 @@
import java.util.Random;

import static hudson.Util.fixEmptyAndTrim;
import static hudson.Util.fixNull;
import static hudson.plugins.android_emulator.AndroidEmulator.log;

public class MonkeyBuilder extends AbstractBuilder {
@@ -59,14 +60,20 @@
@Exported
public final String categories;

/** Extra command line parameters to pass to monkey. */
@Exported
public final String extraParameters;

@DataBoundConstructor
public MonkeyBuilder(String filename, String packageId, Integer eventCount, Integer throttleMs, String seed, String categories) {
public MonkeyBuilder(String filename, String packageId, Integer eventCount, Integer throttleMs, String seed,
String categories, String extraParameters) {
this.filename = fixEmptyAndTrim(filename);
this.packageId = fixEmptyAndTrim(packageId);
this.eventCount = eventCount == null ? 0 : Math.abs(eventCount);
this.throttleMs = throttleMs == null ? 0 : Math.abs(throttleMs);
this.seed = fixEmptyAndTrim(seed) == null ? null : seed.trim().toLowerCase(Locale.ROOT);
this.categories = fixEmptyAndTrim(categories);
this.extraParameters = fixEmptyAndTrim(extraParameters);
}

@Override
@@ -91,9 +98,10 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListen
addArguments(expandedCategory, "-c", cmdArgs, categoryNamesLog);

final long seedValue = parseSeed(seed);
final String expandedExtraParams = fixNull(Utils.expandVariables(build, listener, extraParameters));
final String deviceIdentifier = getDeviceIdentifier(build, listener);
String args = String.format("%s shell monkey -v -v -s %d --throttle %d %s %d", deviceIdentifier, seedValue,
throttleMs, cmdArgs.toString(), eventCount);
String args = String.format("%s shell monkey -v -v -s %d --throttle %d %s %s %d", deviceIdentifier, seedValue,
throttleMs, cmdArgs.toString(), expandedExtraParams, eventCount);

// Determine output filename
String outputFile;
@@ -30,5 +30,10 @@
<f:textbox name="android-emulator.categories" value="${instance.categories}" />
<f:description>${%Zero or more intent categories for the monkey to visit. If not specified, activities with "android.intent.category.LAUNCHER" or "android.intent.category.MONKEY" will be used. Multiple categories can be separated by a comma}</f:description>
</f:entry>

<f:entry title="${%Additional parameters}">
<f:textbox name="android-emulator.extraParameters" value="${instance.extraParameters}" />
<f:description>${%A list of optional command line parameters to pass to monkey. e.g. "--ignore-native-crashes --pct-trackball 0"}</f:description>
</f:entry>
</f:advanced>
</j:jelly>

0 comments on commit a8158e4

Please sign in to comment.