diff --git a/.gitignore b/.gitignore index 3659e7a..f741849 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,7 @@ *.iml target *.log +.project +.classpath +org.eclipse.jdt.core.prefs +work diff --git a/src/main/java/testflight/TestflightRecorder.java b/src/main/java/testflight/TestflightRecorder.java index 7581158..0704cba 100644 --- a/src/main/java/testflight/TestflightRecorder.java +++ b/src/main/java/testflight/TestflightRecorder.java @@ -124,8 +124,14 @@ return this.debug; } + private TestflightTeam [] additionalTeams; + + public TestflightTeam [] getAdditionalTeams() { + return this.additionalTeams; + } + @DataBoundConstructor - public TestflightRecorder(String tokenPairName, Secret apiToken, Secret teamToken, Boolean notifyTeam, String buildNotes, Boolean appendChangelog, String filePath, String dsymPath, String lists, Boolean replace, String proxyHost, String proxyUser, String proxyPass, int proxyPort, Boolean debug) { + public TestflightRecorder(String tokenPairName, Secret apiToken, Secret teamToken, Boolean notifyTeam, String buildNotes, Boolean appendChangelog, String filePath, String dsymPath, String lists, Boolean replace, String proxyHost, String proxyUser, String proxyPass, int proxyPort, Boolean debug, TestflightTeam [] additionalTeams) { this.tokenPairName = tokenPairName; this.apiToken = apiToken; this.teamToken = teamToken; @@ -141,6 +147,7 @@ this.proxyPass = proxyPass; this.proxyPort = proxyPort; this.debug = debug; + this.additionalTeams = additionalTeams; } @Override @@ -164,33 +171,49 @@ String workspace = vars.expand("$WORKSPACE"); - TestflightUploader.UploadRequest ur; + List urList = new ArrayList(); try { - ur = createPartialUploadRequest(vars, build); + TestflightUploader.UploadRequest ur = createPartialUploadRequest(new TestflightTeam(getTokenPairName(), getFilePath(), getDsymPath()), vars, build); + urList.add(ur); } catch (MisconfiguredJobException mje) { listener.getLogger().println(mje.getConfigurationMessage()); return false; } - TestflightRemoteRecorder remoteRecorder = new TestflightRemoteRecorder(workspace, ur, listener); - - final List parsedMaps; - - try { - Object result = launcher.getChannel().call(remoteRecorder); - parsedMaps = (List) result; - } catch (UploadException ue) { - listener.getLogger().println(Messages.TestflightRecorder_IncorrectResponseCode(ue.getStatusCode())); - listener.getLogger().println(ue.getResponseBody()); - return false; + if(additionalTeams != null) { + for(TestflightTeam team : additionalTeams) { + try { + TestflightUploader.UploadRequest ur = createPartialUploadRequest(team, vars, build); + urList.add(ur); + } catch (MisconfiguredJobException mje) { + listener.getLogger().println(mje.getConfigurationMessage()); + return false; + } + + } } - - if (parsedMaps.size() == 0) { - listener.getLogger().println(Messages.TestflightRecorder_NoUploadedFile(ur.filePaths)); - return false; - } - for (Map parsedMap: parsedMaps) { - addTestflightLinks(build, listener, parsedMap); + + for(TestflightUploader.UploadRequest ur : urList) { + TestflightRemoteRecorder remoteRecorder = new TestflightRemoteRecorder(workspace, ur, listener); + + final List parsedMaps; + + try { + Object result = launcher.getChannel().call(remoteRecorder); + parsedMaps = (List) result; + } catch (UploadException ue) { + listener.getLogger().println(Messages.TestflightRecorder_IncorrectResponseCode(ue.getStatusCode())); + listener.getLogger().println(ue.getResponseBody()); + return false; + } + + if (parsedMaps.size() == 0) { + listener.getLogger().println(Messages.TestflightRecorder_NoUploadedFile(ur.filePaths)); + return false; + } + for (Map parsedMap: parsedMaps) { + addTestflightLinks(build, listener, parsedMap); + } } } catch (Throwable e) { listener.getLogger().println(e); @@ -228,11 +251,11 @@ } } - private TestflightUploader.UploadRequest createPartialUploadRequest(EnvVars vars, AbstractBuild build) { + private TestflightUploader.UploadRequest createPartialUploadRequest(TestflightTeam team, EnvVars vars, AbstractBuild build) { TestflightUploader.UploadRequest ur = new TestflightUploader.UploadRequest(); - TokenPair tokenPair = getTokenPair(); - ur.filePaths = vars.expand(StringUtils.trim(filePath)); - ur.dsymPath = vars.expand(StringUtils.trim(dsymPath)); + TokenPair tokenPair = getTokenPair(team.getTokenPairName()); + ur.filePaths = vars.expand(StringUtils.trim(team.getFilePath())); + ur.dsymPath = vars.expand(StringUtils.trim(team.getDsymPath())); ur.apiToken = vars.expand(Secret.toString(tokenPair.getApiToken())); ur.buildNotes = createBuildNotes(vars.expand(buildNotes), build.getChangeSet()); ur.lists = vars.expand(lists); @@ -317,8 +340,8 @@ return actions; } - private TokenPair getTokenPair() { - String tokenPairName = getTokenPairName(); + private TokenPair getTokenPair(String tokenPairName) { + //String tokenPairName = getTokenPairName(); for (TokenPair tokenPair : getDescriptor().getTokenPairs()) { if (tokenPair.getTokenPairName().equals(tokenPairName)) return tokenPair; diff --git a/src/main/java/testflight/TestflightTeam.java b/src/main/java/testflight/TestflightTeam.java new file mode 100644 index 0000000..7a15ebd --- /dev/null +++ b/src/main/java/testflight/TestflightTeam.java @@ -0,0 +1,42 @@ +package testflight; + +import org.kohsuke.stapler.DataBoundConstructor; + +public class TestflightTeam { + + private String tokenPairName; + private String filePath; + private String dsymPath; + + @DataBoundConstructor + public TestflightTeam(String tokenPairName, String filePath, String dsymPath) { + super(); + this.tokenPairName = tokenPairName; + this.filePath = filePath; + this.dsymPath = dsymPath; + } + + public String getTokenPairName() { + return tokenPairName; + } + + public void setTokenPairName(String tokenPairName) { + this.tokenPairName = tokenPairName; + } + + public String getFilePath() { + return filePath; + } + + public void setFilePath(String filePath) { + this.filePath = filePath; + } + + public String getDsymPath() { + return dsymPath; + } + + public void setDsymPath(String dsymPath) { + this.dsymPath = dsymPath; + } +} diff --git a/src/main/resources/testflight/TestflightRecorder/config.jelly b/src/main/resources/testflight/TestflightRecorder/config.jelly index 3405c1e..b319699 100644 --- a/src/main/resources/testflight/TestflightRecorder/config.jelly +++ b/src/main/resources/testflight/TestflightRecorder/config.jelly @@ -23,6 +23,30 @@ + + + + + + + + + + + + + +
+ +
+
+
+
+