Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
bbacd3f
update pom.xml for release
justice3120 Jul 21, 2016
c67f7c1
update pom.xml
justice3120 Jul 22, 2016
776b6a0
add XSS prevention tag to jelly files
justice3120 Jul 22, 2016
d12d424
change to not request API when url or token is empty
justice3120 Jul 22, 2016
503c325
fix fot Findbugs: ES_COMPARING_STRINGS_WITH_EQ
justice3120 Jul 22, 2016
805bd1f
[maven-release-plugin] prepare release open-stf-1.0.0
justice3120 Jul 22, 2016
bdc45b8
[maven-release-plugin] prepare for next development iteration
justice3120 Jul 22, 2016
e461c23
[maven-release-plugin] rollback the release of open-stf-1.0.0
justice3120 Jul 22, 2016
9b2f489
[maven-release-plugin] prepare release open-stf-1.0.0
justice3120 Jul 22, 2016
8de5f8b
[maven-release-plugin] rollback the release of open-stf-1.0.0
justice3120 Jul 22, 2016
f9b20bc
[maven-release-plugin] prepare release open-stf-1.0.0
justice3120 Jul 22, 2016
4503d6f
[maven-release-plugin] rollback the release of open-stf-1.0.0
justice3120 Jul 22, 2016
e5ffbbf
[maven-release-plugin] prepare release open-stf-1.0.0
justice3120 Jul 22, 2016
b06960a
[maven-release-plugin] rollback the release of open-stf-1.0.0
justice3120 Jul 22, 2016
54defe4
[maven-release-plugin] prepare release open-stf-1.0.0
justice3120 Jul 22, 2016
3858bb4
[maven-release-plugin] rollback the release of open-stf-1.0.0
justice3120 Jul 22, 2016
113fec3
[maven-release-plugin] prepare release open-stf-1.0.0
justice3120 Jul 22, 2016
8003e01
[maven-release-plugin] rollback the release of open-stf-1.0.0
justice3120 Jul 22, 2016
aa6c503
[maven-release-plugin] prepare release open-stf-1.0.0
justice3120 Jul 22, 2016
8dc20b3
[maven-release-plugin] prepare for next development iteration
justice3120 Jul 22, 2016
679b662
[maven-release-plugin] rollback the release of open-stf-1.0.0
justice3120 Jul 22, 2016
3dc9d0d
[maven-release-plugin] prepare release open-stf-1.0.0
justice3120 Jul 22, 2016
23396c7
[maven-release-plugin] prepare for next development iteration
justice3120 Jul 22, 2016
9309ed6
[maven-release-plugin] rollback the release of open-stf-1.0.0
justice3120 Jul 22, 2016
fb04a81
[maven-release-plugin] prepare release open-stf-1.0.0
justice3120 Jul 22, 2016
faef82b
[maven-release-plugin] prepare for next development iteration
justice3120 Jul 22, 2016
fe14d9f
change 'jQuery' to 'Q' in balloon.js
justice3120 Aug 18, 2016
57b649a
[maven-release-plugin] prepare release open-stf-1.0.1
justice3120 Sep 8, 2016
6605ded
[maven-release-plugin] prepare for next development iteration
justice3120 Sep 8, 2016
7c06faa
[maven-release-plugin] rollback the release of open-stf-1.0.1
justice3120 Sep 8, 2016
5a93c12
[maven-release-plugin] prepare release open-stf-1.0.1
justice3120 Sep 8, 2016
0f7ee9c
[maven-release-plugin] rollback the release of open-stf-1.0.1
justice3120 Sep 8, 2016
1a6ff34
[maven-release-plugin] prepare release open-stf-1.0.1
justice3120 Sep 8, 2016
0e3735b
[maven-release-plugin] rollback the release of open-stf-1.0.1
justice3120 Sep 8, 2016
a0d5832
[maven-release-plugin] prepare release open-stf-1.0.1
justice3120 Sep 8, 2016
8570d8e
[maven-release-plugin] prepare for next development iteration
justice3120 Sep 8, 2016
4c57648
[maven-release-plugin] rollback the release of open-stf-1.0.1
justice3120 Sep 9, 2016
5ff4960
delete unnecessary lines in pom.xml
justice3120 Sep 9, 2016
05e08a3
[maven-release-plugin] prepare release open-stf-1.0.1
justice3120 Sep 9, 2016
a29b57a
[maven-release-plugin] rollback the release of open-stf-1.0.1
justice3120 Sep 9, 2016
855594e
[maven-release-plugin] prepare release open-stf-1.0.1
justice3120 Sep 9, 2016
d919aa5
[maven-release-plugin] rollback the release of open-stf-1.0.1
justice3120 Sep 9, 2016
3ee0e9d
[maven-release-plugin] prepare release open-stf-1.0.1
justice3120 Sep 9, 2016
d23150a
[maven-release-plugin] prepare for next development iteration
justice3120 Sep 9, 2016
edafd03
Merge pull request #1 from jenkinsci/jquery_confrict
justice3120 Sep 9, 2016
f6afb3a
improve validation
justice3120 Oct 24, 2016
40c0300
fix for checkstyle: CustomImportOrderCheck
justice3120 Oct 24, 2016
9378d17
fix for checkstyle: IndentationCheck
justice3120 Oct 24, 2016
ee3ad85
fix for checkstyle: JavadocCheck
justice3120 Oct 24, 2016
e4dbad6
[maven-release-plugin] prepare release open-stf-1.0.2
justice3120 Oct 24, 2016
608bf85
[maven-release-plugin] prepare for next development iteration
justice3120 Oct 24, 2016
93bddae
Merge pull request #2 from jenkinsci/improve_validation
justice3120 Oct 24, 2016
015f779
add console log about reserved device information
justice3120 Oct 26, 2016
de8801a
add publishing device information feature
justice3120 Oct 27, 2016
97418cd
fix for checkstyle: IndentationCheck
justice3120 Oct 27, 2016
f0e5090
fix for checkstyle: JavadocMethodCheck
justice3120 Oct 27, 2016
fd9b5fd
delete comment
justice3120 Oct 27, 2016
5353146
[maven-release-plugin] prepare release open-stf-1.0.3
justice3120 Oct 27, 2016
e4b44f5
[maven-release-plugin] prepare for next development iteration
justice3120 Oct 27, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 9 additions & 14 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@

<artifactId>open-stf</artifactId>
<packaging>hpi</packaging>
<version>1.4.0</version>
<version>1.0.4-SNAPSHOT</version>
<name>Open STF Plugin</name>
<url>https://wiki.jenkins-ci.org/display/JENKINS/Open+STF+Plugin</url>
<developers>
<developer>
<id>justice3120</id>
Expand Down Expand Up @@ -88,12 +89,6 @@

<build>
<plugins>
<plugin>
<artifactId>maven-release-plugin</artifactId>
<configuration>
<goals>deploy</goals>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
Expand Down Expand Up @@ -156,6 +151,13 @@
</testResources>
</build>

<scm>
<connection>scm:git:git://github.com/jenkinsci/open-stf-plugin.git</connection>
<developerConnection>scm:git:git@github.com:jenkinsci/open-stf-plugin.git</developerConnection>
<url>https://github.com/jenkinsci/open-stf-plugin</url>
<tag>HEAD</tag>
</scm>

<reporting>
<plugins>
<plugin>
Expand All @@ -176,13 +178,6 @@
</plugins>
</reporting>

<distributionManagement>
<repository>
<id>maven.jenkins-ci.org</id>
<url>http://maven.jenkins-ci.org:8081/content/repositories/releases/</url>
</repository>
</distributionManagement>

<repositories>
<repository>
<id>github-maven</id>
Expand Down
64 changes: 43 additions & 21 deletions src/main/java/hudson/plugins/openstf/STFBuildWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import static hudson.plugins.android_emulator.AndroidEmulator.log;

import jenkins.model.Jenkins;
import hudson.EnvVars;
import hudson.Extension;
import hudson.FilePath;
Expand Down Expand Up @@ -31,6 +30,7 @@
import hudson.util.ListBoxModel;
import hudson.util.NullStream;
import io.swagger.client.model.DeviceListResponseDevices;
import jenkins.model.Jenkins;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.kohsuke.stapler.DataBoundConstructor;
Expand Down Expand Up @@ -119,6 +119,14 @@ public Environment setUp(AbstractBuild build, final Launcher launcher, BuildList
androidHome = hudson.plugins.android_emulator.util.Utils
.discoverAndroidHome(launcher, node, envVars, androidHome);

// Validate Setting values
String configError = isConfigValid(stfApiEndpoint, stfToken);
if (configError != null) {
log(logger, Messages.ERROR_MISCONFIGURED(configError));
build.setResult(Result.NOT_BUILT);
return null;
}

// Confirm that the required SDK tools are available
AndroidSdk androidSdk = hudson.plugins.android_emulator.util.Utils
.getAndroidSdk(launcher, androidHome, null);
Expand Down Expand Up @@ -165,6 +173,9 @@ private Environment doSetup(final AbstractBuild<?, ?> build, final Launcher laun
String reservedDeviceId = stfConfig.reserve();
DeviceListResponseDevices device = Utils.getSTFDeviceById(reservedDeviceId);
remote.setDevice(device);
log(logger, Messages.SHOW_RESERVED_DEVICE_INFO(device.name, device.serial,
device.sdk, device.version));
build.addAction(new STFReservedDeviceAction(descriptor.stfApiEndpoint, device));
} catch (STFException ex) {
log(logger, ex.getMessage());
build.setResult(Result.NOT_BUILT);
Expand Down Expand Up @@ -322,6 +333,23 @@ private void cleanUp(STFConfig stfConfig, AndroidRemoteContext remote, Proc logc
remote.cleanUp();
}

private String isConfigValid(String stfApiEndpoint, String stfToken) {

if (stfApiEndpoint == null || stfApiEndpoint.equals("")) {
return Messages.API_ENDPOINT_URL_NOT_SET();
}
FormValidation result = descriptor.doCheckSTFApiEndpoint(stfApiEndpoint);
if (FormValidation.Kind.ERROR == result.kind) {
return result.getMessage();
}
result = descriptor.doCheckSTFToken(stfApiEndpoint, stfToken);
if (FormValidation.Kind.ERROR == result.kind) {
return result.getMessage();
}

return null;
}

private boolean waitForSTFDeviceConnectCompletion(final int timeout,
AndroidRemoteContext remote) {

Expand Down Expand Up @@ -434,29 +462,19 @@ public ListBoxModel doFillConditionNameItems() {
return Utils.getSTFDeviceAttributeListBoxItems();
}

public ComboBoxModel doFillConditionValueItems(@QueryParameter String conditionName) {
Utils.setupSTFApiClient(stfApiEndpoint, stfToken);
return Utils.getSTFDeviceAttributeValueComboBoxItems(conditionName);
}

/**
* Setting device model values on jelly.
* This method is called by Jenkins.
* @return List of Device Model values.
*/
public ComboBoxModel doFillModelItems() {
Utils.setupSTFApiClient(stfApiEndpoint, stfToken);
return Utils.getSTFDeviceAttributeValueComboBoxItems("model");
}

/**
* Setting OS version values on jelly.
* Fill condition value items on Jenkins web view.
* This method is called by Jenkins.
* @return List of OS version values.
* @param conditionName Condition name to get values.
* @return condition value items.
*/
public ComboBoxModel doFillVersionItems() {
Utils.setupSTFApiClient(stfApiEndpoint, stfToken);
return Utils.getSTFDeviceAttributeValueComboBoxItems("version");
public ComboBoxModel doFillConditionValueItems(@QueryParameter String conditionName) {
if (Util.fixEmpty(stfApiEndpoint) == null || Util.fixEmpty(stfToken) == null) {
return new ComboBoxModel();
} else {
Utils.setupSTFApiClient(stfApiEndpoint, stfToken);
return Utils.getSTFDeviceAttributeValueComboBoxItems(conditionName);
}
}

/**
Expand Down Expand Up @@ -504,6 +522,10 @@ public FormValidation doCheckUseSpecificKey(@QueryParameter Boolean value) {
@JavaScriptMethod
public JSONArray getDeviceListJSON(JSONObject filter) {

if (Util.fixEmpty(stfApiEndpoint) == null || Util.fixEmpty(stfToken) == null) {
return new JSONArray();
}

if (!Utils.validateDeviceFilter(filter)) {
return new JSONArray();
}
Expand Down
57 changes: 57 additions & 0 deletions src/main/java/hudson/plugins/openstf/STFReservedDeviceAction.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package hudson.plugins.openstf;

import hudson.model.Action;
import hudson.plugins.openstf.Messages;
import io.swagger.client.model.DeviceListResponseDevices;
import org.kohsuke.stapler.export.Exported;

import java.net.URL;

public class STFReservedDeviceAction implements Action {
private final String stfApiEndpoint;
private final DeviceListResponseDevices reservedDevice;

public STFReservedDeviceAction(String stfApiEndpoint, DeviceListResponseDevices reservedDevice) {
this.stfApiEndpoint = stfApiEndpoint;
this.reservedDevice = reservedDevice;
}

/**
* Get the device image URL.
* This method is called by Jenkins.
* return image URL
*/
@Exported
public String getDeviceIcon() {
String path = "/static/app/devices/icon/x120/";
if (reservedDevice.image != null) {
path += reservedDevice.image;
} else {
path += "_default.jpg";
}
try {
URL iconUrl = new URL(new URL(stfApiEndpoint), path);
return iconUrl.toString();
} catch (Exception ex) {
return "";
}
}

@Exported
public String getSummary() {
return Messages.PUBLISH_RESERVED_DEVICE_INFO(reservedDevice.name, reservedDevice.sdk,
reservedDevice.version);
}

public String getDisplayName() {
return null;
}

public String getIconFileName() {
return null;
}

public String getUrlName() {
return null;
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package hudson.plugins.openstf.axis;

import jenkins.model.Jenkins;
import hudson.Extension;
import hudson.matrix.Axis;
import hudson.matrix.AxisDescriptor;
import hudson.plugins.openstf.STFBuildWrapper;
import hudson.plugins.openstf.util.Utils;
import hudson.util.ListBoxModel;
import jenkins.model.Jenkins;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.kohsuke.stapler.DataBoundConstructor;
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/hudson/plugins/openstf/util/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ public static FormValidation validateSTFApiEndpoint(String stfApiEndpoint) {

ApiClient stfApiClient = new ApiClient();
stfApiClient.setBasePath(stfApiEndpoint);
stfApiClient.setConnectTimeout(10 * 1000);
UserApi stfUserApi = new UserApi(stfApiClient);
try {
stfUserApi.getUser();
Expand All @@ -356,6 +357,8 @@ public static FormValidation validateSTFApiEndpoint(String stfApiEndpoint) {
String message = ex.getMessage();
if (message.startsWith("java.net.UnknownHostException:")) {
return FormValidation.error(Messages.CANNOT_RESOLVE_HOST());
} else if (message.startsWith("java.net.SocketTimeoutException:")) {
return FormValidation.error(Messages.CONNECTION_TIMEOUT());
} else if (message.startsWith("java.net.ConnectException:")) {
return FormValidation.error(message.replaceAll("java.net.ConnectException: ", ""));
} else {
Expand Down
8 changes: 8 additions & 0 deletions src/main/resources/hudson/plugins/openstf/Messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
MALFORMED_STF_API_ENDPOINT_URL=STF API endpoint URL is malformed
INVALID_STF_API_ENDPOINT_URL=URL seems not valid as the STF API endpoint
CANNOT_RESOLVE_HOST=Cannot resolve this host name
CONNECTION_TIMEOUT=Connection time out.
STF_API_ENDPOINT_NOT_SET=Please set STF API endpoint URL first
STF_TOKEN_REQUIRED=STF token is required
STF_TOKEN_NOT_VALID=STF token is not valid
Expand All @@ -15,6 +16,9 @@ INVALID_REGEXP_VALUE=Invalid Regex value
# Execution
CANNOT_GET_HUDSON_INSTANCE=Could not get any hudson instances on this build
INVALID_DEVICE_CONDITION_SET_IS_GIVEN=Invalid device condition set was given. Please check your job setting.
API_ENDPOINT_URL_NOT_SET=The STF API Endpoint URL has not been set.
ERROR_MISCONFIGURED=Cannot use the Open STF due to misconfiguration: {0}
SHOW_RESERVED_DEVICE_INFO=Reserved Device Info:\n Name: {0}\n Serial: {1}\n API Level:{2}\n OS Version: {3}
OVERWRITE_ADBKEY_FILE=Overwriting ADB key file at ''{0}''
ADBKEY_IS_NOT_SET=ADB key file is not set. Skip overwriting
START_WAITING_STF_DEVICE_RELEASED=Waiting for the STF device to be released...
Expand All @@ -24,3 +28,7 @@ CONNECTING_STF_DEVICE_FAILED=Connecting to the STF divice is failed
CANNOT_GET_WORKSPACE_ON_THIS_BUILD=Could not get workspace directory on this build
INTERRUPTED_DURING_STF_DEVICE_CONNECT_COMPLETION=Interrupted while waiting for the connection to the STF device to complete
COULD_NOT_CHECK_STF_DEVICE_CONNECT_COMPLETION=Could not check for the STF device connect completion

# Publish

PUBLISH_RESERVED_DEVICE_INFO=Built with "{0}" (API Level={1}, OS Version={2})
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">

<script type="text/javascript" src="${rootURL}/plugin/open-stf/js/vendor/jquery.balloon.min.js" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">

<f:section title="${%Open STF}">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form" xmlns:i="jelly:fmt">

<f:block>
<tr>
<td style="width: 48px; margin-right:1em;">
<img src="${it.deviceIcon}" style="height: 48px; display: block; margin-left: auto; margin-right: auto;" />
</td>
<td style="vertical-align:middle">${it.summary}</td>
</tr>
</f:block>

</j:jelly>
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">
<f:entry title="${%Name}" field="name">
<f:textbox default="" />
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/index.jelly
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<?jelly escape-by-default='true'?>
<div>
Reserve a STF device before a build, then release it after.
</div>
Loading