Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@
*.iml
target
*.log

.DS_Store
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Change Log
==========

Version 1.1.1 *(2018-04-18)*
--------------------------

* Add support for release notes

Version 1.1.0 *(2014-11-28)*
--------------------------

Expand All @@ -10,4 +15,3 @@ Version 1.0.0 *(2012-09-17)*
--------------------------

Initial release

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Download/Install

Download and install this plugin file into your Jenkins instance.

[Download link](https://raw.githubusercontent.com/jfsso/deploygate-plugin/master/bin/deploygate-1.1.0.hpi) (version 1.1.0)
[Download link](https://raw.githubusercontent.com/jfsso/deploygate-plugin/master/bin/deploygate-1.1.1.hpi) (version 1.1.1)

Credits
-------
Expand Down
Binary file added bin/deploygate-1.1.1.hpi
Binary file not shown.
138 changes: 69 additions & 69 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,71 +1,71 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>1.399</version><!-- which version of Jenkins is this plugin built against? -->
</parent>

<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>deploygate</artifactId>
<name>DeployGate Plugin</name>
<description>Uploads .apk files to www.deploygate.com</description>
<version>1.1.0</version>
<packaging>hpi</packaging>

<!-- get every artifact through maven.glassfish.org, which proxies all the artifacts that we need -->
<repositories>
<repository>
<id>repo.jenkins-ci.org</id>
<url>http://repo.jenkins-ci.org/public/</url>
</repository>
</repositories>

<scm>
<connection>scm:git:ssh://github.com/jfsso/deploygate-plugin.git</connection>
<developerConnection>scm:git:ssh://git@github.com/jfsso/deploygate-plugin.git</developerConnection>
<url>https://github.com/jfsso/deploygate-plugin</url>
</scm>

<url>http://wiki.jenkins-ci.org/display/JENKINS/DeployGate+Plugin</url>


<developers>
<developer>
<id>jfsso</id>
<name>Joao Orui</name>
<email>fsantiago@gmail.com</email>
</developer>
</developers>
<pluginRepositories>
<pluginRepository>
<id>repo.jenkins-ci.org</id>
<url>http://repo.jenkins-ci.org/public/</url>
</pluginRepository>
</pluginRepositories>

<dependencies>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>${httpclient.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
<version>${httpclient.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1</version>
<scope>compile</scope>
</dependency>
</dependencies>

<properties>
<httpclient.version>4.0.1</httpclient.version>
</properties>
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>3.4</version><!-- which version of Jenkins is this plugin built against? -->
<relativePath />
</parent>
<groupId>io.jenkins.plugins</groupId>
<artifactId>deploygate</artifactId>
<version>1.1.1</version>
<packaging>hpi</packaging>
<properties>
<jenkins.version>2.7.3</jenkins.version>
<java.level>7</java.level>
<httpclient.version>4.5.5</httpclient.version>
</properties>
<name>DeployGate Plugin</name>
<description>Uploads .ipa/.apk files to www.deploygate.com</description>
<dependencies>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>${httpclient.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
<version>${httpclient.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1</version>
<scope>compile</scope>
</dependency>
</dependencies>

<!-- get every artifact through maven.glassfish.org, which proxies all the artifacts that we need -->
<repositories>
<repository>
<id>repo.jenkins-ci.org</id>
<url>http://repo.jenkins-ci.org/public/</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>repo.jenkins-ci.org</id>
<url>https://repo.jenkins-ci.org/public/</url>
</pluginRepository>
</pluginRepositories>

<scm>
<connection>scm:git:ssh://github.com/jfsso/deploygate-plugin.git</connection>
<developerConnection>scm:git:ssh://git@github.com/jfsso/deploygate-plugin.git</developerConnection>
<url>https://github.com/jfsso/deploygate-plugin</url>
</scm>

<url>http://wiki.jenkins-ci.org/display/JENKINS/DeployGate+Plugin</url>

<developers>
<developer>
<id>jfsso</id>
<name>Joao Orui</name>
<email>fsantiago@gmail.com</email>
</developer>
</developers>
</project>
38 changes: 37 additions & 1 deletion src/main/java/deploygate/DeploygateRecorder.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,15 @@
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.io.File;
import java.nio.charset.StandardCharsets;
import java.io.IOException;

import net.sf.json.JSONObject;

import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.Predicate;
import org.apache.commons.io.FileUtils;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.StaplerRequest;

Expand All @@ -47,6 +51,18 @@ public String getBuildNotes() {
return this.buildNotes;
}

private String releaseNotes;

public String getReleaseNotes() {
return this.releaseNotes;
}

private String releaseNotesFilePath;

public String getReleaseNotesFilePath() {
return this.releaseNotesFilePath;
}

private String filePath;

public String getFilePath() {
Expand Down Expand Up @@ -85,11 +101,15 @@ public int getProxyPort() {

@DataBoundConstructor
public DeploygateRecorder(String apiToken, String userName,
String buildNotes, String filePath,String distributionKey, String proxyHost,
String buildNotes, String releaseNotes, String releaseNotesFilePath,
String filePath, String distributionKey,
String proxyHost,
String proxyUser, String proxyPass, int proxyPort) {
this.apiToken = apiToken;
this.userName = userName;
this.buildNotes = buildNotes;
this.releaseNotes = releaseNotes;
this.releaseNotesFilePath = releaseNotesFilePath;
this.filePath = filePath;
this.distributionKey = distributionKey;
this.proxyHost = proxyHost;
Expand Down Expand Up @@ -166,6 +186,22 @@ private DeploygateUploader.UploadRequest createPartialUploadRequest(
ur.filePath = vars.expand(expandPath);
ur.apiToken = vars.expand(apiToken);
ur.buildNotes = vars.expand(buildNotes);

String expandedReleaseNotes = vars.expand(releaseNotes);
String expandedReleaseNotesFilePath = vars.expand(releaseNotesFilePath);

if(expandedReleaseNotesFilePath.isEmpty()) ur.releaseNotes = expandedReleaseNotes;
else {
try {
ur.releaseNotes = expandedReleaseNotes
+ FileUtils.readFileToString(
new File(vars.get("WORKSPACE", ""), expandedReleaseNotesFilePath), StandardCharsets.UTF_8);
}
catch (IOException ex) {
ur.releaseNotes = expandedReleaseNotes;
}
}

ur.distributionKey = distributionKey;
ur.proxyHost = proxyHost;
ur.proxyPass = proxyPass;
Expand Down
20 changes: 10 additions & 10 deletions src/main/java/deploygate/DeploygateRemoteRecorder.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
package deploygate;

import hudson.model.BuildListener;
import hudson.remoting.Callable;
import jenkins.security.MasterToSlaveCallable;

import java.io.File;
import java.io.Serializable;
import java.nio.charset.StandardCharsets;

import org.apache.commons.lang.StringUtils;

/**
* Code for sending a build to TestFlight which can run on a master or slave.
* Code for sending a build to Deploygate which can run on a master or slave.
*/
public class DeploygateRemoteRecorder implements Callable<Object, Throwable>,
Serializable {
public class DeploygateRemoteRecorder extends MasterToSlaveCallable {
final private boolean pathSpecified;
final private DeploygateUploader.UploadRequest uploadRequest;
final private BuildListener listener;
Expand All @@ -26,31 +26,31 @@ public DeploygateRemoteRecorder(boolean pathSpecified,
}

public Object call() throws Throwable {
uploadRequest.file = identifyApk();
uploadRequest.file = identifyApp();

listener.getLogger().println(uploadRequest.file);

DeploygateUploader uploader = new DeploygateUploader();
return uploader.upload(uploadRequest);
}

private File identifyApk() {
private File identifyApp() {
if (pathSpecified) {
return new File(uploadRequest.filePath);
} else {
File workspaceDir = new File(uploadRequest.filePath);
File possibleIpa = DeploygateRemoteRecorder.findApk(workspaceDir);
File possibleIpa = DeploygateRemoteRecorder.findApp(workspaceDir);
return possibleIpa != null ? possibleIpa : workspaceDir;
}
}

public static File findApk(File root) {
public static File findApp(File root) {
for (File file : root.listFiles()) {
if (file.isDirectory()) {
File ipaResult = findApk(file);
File ipaResult = findApp(file);
if (ipaResult != null)
return ipaResult;
} else if (file.getName().endsWith(".apk")) {
} else if (file.getName().endsWith(".apk") || file.getName().endsWith(".ipa")) {
return file;
}
}
Expand Down
20 changes: 9 additions & 11 deletions src/main/java/deploygate/DeploygateUploader.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import java.io.Serializable;
import java.util.Map;
import java.util.Scanner;
import java.nio.charset.StandardCharsets;

import org.apache.http.HttpEntity;
import org.apache.http.HttpHost;
Expand All @@ -32,6 +33,7 @@ static class UploadRequest implements Serializable {
String filePath;
String apiToken;
String buildNotes;
String releaseNotes;
String distributionKey;
File file;
String proxyHost;
Expand All @@ -40,23 +42,19 @@ static class UploadRequest implements Serializable {
int proxyPort;
}

public Map upload(UploadRequest ur) throws IOException,
org.json.simple.parser.ParseException {
public Map upload(UploadRequest ur) throws IOException, org.json.simple.parser.ParseException {

DefaultHttpClient httpClient = new DefaultHttpClient();

// Configure the proxy if necessary
if (ur.proxyHost != null && !ur.proxyHost.isEmpty() && ur.proxyPort > 0) {
Credentials cred = null;
if (ur.proxyUser != null && !ur.proxyUser.isEmpty())
cred = new UsernamePasswordCredentials(ur.proxyUser,
ur.proxyPass);
cred = new UsernamePasswordCredentials(ur.proxyUser, ur.proxyPass);

httpClient.getCredentialsProvider().setCredentials(
new AuthScope(ur.proxyHost, ur.proxyPort), cred);
httpClient.getCredentialsProvider().setCredentials(new AuthScope(ur.proxyHost, ur.proxyPort), cred);
HttpHost proxy = new HttpHost(ur.proxyHost, ur.proxyPort);
httpClient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY,
proxy);
httpClient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
}

HttpHost targetHost = new HttpHost("deploygate.com", 443, "https");
Expand All @@ -65,7 +63,8 @@ public Map upload(UploadRequest ur) throws IOException,

MultipartEntity entity = new MultipartEntity();
entity.addPart("token", new StringBody(ur.apiToken));
entity.addPart("message", new StringBody(ur.buildNotes));
entity.addPart("message", new StringBody(ur.buildNotes, StandardCharsets.UTF_8));
entity.addPart("release_note", new StringBody(ur.releaseNotes, StandardCharsets.UTF_8));
if(ur.distributionKey != null && ! ur.distributionKey.isEmpty()) {
entity.addPart("distribution_key", new StringBody(ur.distributionKey));
}
Expand All @@ -86,7 +85,6 @@ public Map upload(UploadRequest ur) throws IOException,

JSONParser parser = new JSONParser();

return (Map) parser
.parse(new BufferedReader(new InputStreamReader(is)));
return (Map)parser.parse(new BufferedReader(new InputStreamReader(is)));
}
}
2 changes: 2 additions & 0 deletions src/main/java/deploygate/DeploygateUploaderMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
public class DeploygateUploaderMain {
/**
* Useful for testing
* @param args Command line arguments
* @throws Exception
*/
public static void main(String[] args) throws Exception {
DeploygateUploader uploader = new DeploygateUploader();
Expand Down
Binary file removed src/main/resources/.DS_Store
Binary file not shown.
6 changes: 6 additions & 0 deletions src/main/resources/deploygate/DeploygateRecorder/config.jelly
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@
<f:entry title="Build Notes" field="buildNotes">
<f:textarea />
</f:entry>
<f:entry title="Release Notes" field="releaseNotes">
<f:textarea />
</f:entry>
<f:entry title="Release Notes File Path" field="releaseNotesFilePath">
<f:textbox />
</f:entry>
<f:advanced>
<f:entry title="Distribution Key" field="distributionKey">
<f:textbox />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<div>
A file path to release notes text file.<br />
This will be appended after above text pane's content.
</div>
Loading