diff --git a/.gitignore b/.gitignore index 65b3cb9..eb5a576 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,5 @@ *.iml target *.log + +.DS_Store \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f6092a..102fa50 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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)* -------------------------- @@ -10,4 +15,3 @@ Version 1.0.0 *(2012-09-17)* -------------------------- Initial release - diff --git a/README.md b/README.md index 603625b..687d2f0 100644 --- a/README.md +++ b/README.md @@ -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 ------- diff --git a/bin/deploygate-1.1.1.hpi b/bin/deploygate-1.1.1.hpi new file mode 100644 index 0000000..362467b Binary files /dev/null and b/bin/deploygate-1.1.1.hpi differ diff --git a/pom.xml b/pom.xml index 26246cc..18c5fa9 100644 --- a/pom.xml +++ b/pom.xml @@ -1,71 +1,71 @@ + - 4.0.0 - - org.jenkins-ci.plugins - plugin - 1.399 - - - org.jenkins-ci.plugins - deploygate - DeployGate Plugin - Uploads .apk files to www.deploygate.com - 1.1.0 - hpi - - - - - repo.jenkins-ci.org - http://repo.jenkins-ci.org/public/ - - - - - scm:git:ssh://github.com/jfsso/deploygate-plugin.git - scm:git:ssh://git@github.com/jfsso/deploygate-plugin.git - https://github.com/jfsso/deploygate-plugin - - - http://wiki.jenkins-ci.org/display/JENKINS/DeployGate+Plugin - - - - - jfsso - Joao Orui - fsantiago@gmail.com - - - - - repo.jenkins-ci.org - http://repo.jenkins-ci.org/public/ - - - - - - org.apache.httpcomponents - httpclient - ${httpclient.version} - compile - - - org.apache.httpcomponents - httpmime - ${httpclient.version} - compile - - - com.googlecode.json-simple - json-simple - 1.1 - compile - - - - - 4.0.1 - + 4.0.0 + + org.jenkins-ci.plugins + plugin + 3.4 + + + io.jenkins.plugins + deploygate + 1.1.1 + hpi + + 2.7.3 + 7 + 4.5.5 + + DeployGate Plugin + Uploads .ipa/.apk files to www.deploygate.com + + + org.apache.httpcomponents + httpclient + ${httpclient.version} + compile + + + org.apache.httpcomponents + httpmime + ${httpclient.version} + compile + + + com.googlecode.json-simple + json-simple + 1.1 + compile + + + + + + + repo.jenkins-ci.org + http://repo.jenkins-ci.org/public/ + + + + + repo.jenkins-ci.org + https://repo.jenkins-ci.org/public/ + + + + + scm:git:ssh://github.com/jfsso/deploygate-plugin.git + scm:git:ssh://git@github.com/jfsso/deploygate-plugin.git + https://github.com/jfsso/deploygate-plugin + + + http://wiki.jenkins-ci.org/display/JENKINS/DeployGate+Plugin + + + + jfsso + Joao Orui + fsantiago@gmail.com + + diff --git a/src/main/java/deploygate/DeploygateRecorder.java b/src/main/java/deploygate/DeploygateRecorder.java index 71e6089..0decf3e 100644 --- a/src/main/java/deploygate/DeploygateRecorder.java +++ b/src/main/java/deploygate/DeploygateRecorder.java @@ -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; @@ -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() { @@ -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; @@ -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; diff --git a/src/main/java/deploygate/DeploygateRemoteRecorder.java b/src/main/java/deploygate/DeploygateRemoteRecorder.java index cb23b84..d36b888 100644 --- a/src/main/java/deploygate/DeploygateRemoteRecorder.java +++ b/src/main/java/deploygate/DeploygateRemoteRecorder.java @@ -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, - Serializable { +public class DeploygateRemoteRecorder extends MasterToSlaveCallable { final private boolean pathSpecified; final private DeploygateUploader.UploadRequest uploadRequest; final private BuildListener listener; @@ -26,7 +26,7 @@ public DeploygateRemoteRecorder(boolean pathSpecified, } public Object call() throws Throwable { - uploadRequest.file = identifyApk(); + uploadRequest.file = identifyApp(); listener.getLogger().println(uploadRequest.file); @@ -34,23 +34,23 @@ public Object call() throws Throwable { 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; } } diff --git a/src/main/java/deploygate/DeploygateUploader.java b/src/main/java/deploygate/DeploygateUploader.java index 27f9ceb..ded0462 100644 --- a/src/main/java/deploygate/DeploygateUploader.java +++ b/src/main/java/deploygate/DeploygateUploader.java @@ -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; @@ -32,6 +33,7 @@ static class UploadRequest implements Serializable { String filePath; String apiToken; String buildNotes; + String releaseNotes; String distributionKey; File file; String proxyHost; @@ -40,8 +42,7 @@ 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(); @@ -49,14 +50,11 @@ public Map upload(UploadRequest ur) throws IOException, 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"); @@ -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)); } @@ -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))); } } diff --git a/src/main/java/deploygate/DeploygateUploaderMain.java b/src/main/java/deploygate/DeploygateUploaderMain.java index d4c1452..912f0bc 100644 --- a/src/main/java/deploygate/DeploygateUploaderMain.java +++ b/src/main/java/deploygate/DeploygateUploaderMain.java @@ -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(); diff --git a/src/main/resources/.DS_Store b/src/main/resources/.DS_Store deleted file mode 100644 index 3dce823..0000000 Binary files a/src/main/resources/.DS_Store and /dev/null differ diff --git a/src/main/resources/deploygate/DeploygateRecorder/config.jelly b/src/main/resources/deploygate/DeploygateRecorder/config.jelly index b324774..2fbd8ba 100644 --- a/src/main/resources/deploygate/DeploygateRecorder/config.jelly +++ b/src/main/resources/deploygate/DeploygateRecorder/config.jelly @@ -21,6 +21,12 @@ + + + + + + diff --git a/src/main/resources/deploygate/DeploygateRecorder/help-releaseNotesFilePath.html b/src/main/resources/deploygate/DeploygateRecorder/help-releaseNotesFilePath.html new file mode 100644 index 0000000..d23c968 --- /dev/null +++ b/src/main/resources/deploygate/DeploygateRecorder/help-releaseNotesFilePath.html @@ -0,0 +1,4 @@ +
+ A file path to release notes text file.
+ This will be appended after above text pane's content. +
diff --git a/src/main/resources/index.jelly b/src/main/resources/index.jelly index bf75dd6..e396e9c 100644 --- a/src/main/resources/index.jelly +++ b/src/main/resources/index.jelly @@ -2,5 +2,5 @@ This view is used to render the installed plugins page. -->
- This plugin will upload a .apk file to deploygate.com for distribution. + This plugin will upload a .ipa/.apk file to deploygate.com for distribution.