forked from jweinberg/testflight-plugin
-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Patch 1 #6
Closed
Closed
Patch 1 #6
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,8 @@ | |
import hudson.model.AbstractBuild; | ||
import hudson.tasks.*; | ||
import hudson.util.RunList; | ||
import hudson.scm.ChangeLogSet.*; | ||
import hudson.scm.ChangeLogSet; | ||
import org.apache.commons.collections.Predicate; | ||
import org.apache.http.HttpEntity; | ||
import org.apache.http.HttpHost; | ||
|
@@ -32,6 +34,7 @@ | |
import org.apache.commons.lang.StringUtils; | ||
import org.kohsuke.stapler.StaplerRequest; | ||
|
||
|
||
public class TestflightRecorder extends Recorder | ||
{ | ||
private String apiToken; | ||
|
@@ -52,6 +55,12 @@ public Boolean getNotifyTeam() | |
return this.notifyTeam; | ||
} | ||
|
||
private Boolean sendSCMchanges; | ||
public Boolean getSendSCMchanges() | ||
{ | ||
return this.sendSCMchanges; | ||
} | ||
|
||
private String buildNotes; | ||
public String getBuildNotes() | ||
{ | ||
|
@@ -107,12 +116,13 @@ public int getProxyPort() | |
} | ||
|
||
@DataBoundConstructor | ||
public TestflightRecorder(String apiToken, String teamToken, Boolean notifyTeam, String buildNotes, String filePath, String dsymPath, String lists, Boolean replace, String proxyHost, String proxyUser, String proxyPass, int proxyPort) | ||
public TestflightRecorder(String apiToken, String teamToken, Boolean notifyTeam, Boolean sendSCMchanges, String buildNotes, String filePath, String dsymPath, String lists, Boolean replace, String proxyHost, String proxyUser, String proxyPass, int proxyPort) | ||
{ | ||
this.teamToken = teamToken; | ||
this.apiToken = apiToken; | ||
this.notifyTeam = notifyTeam; | ||
this.buildNotes = buildNotes; | ||
this.sendSCMchanges = sendSCMchanges; | ||
this.buildNotes = buildNotes; | ||
this.filePath = filePath; | ||
this.dsymPath = dsymPath; | ||
this.replace = replace; | ||
|
@@ -178,10 +188,29 @@ public boolean perform(AbstractBuild build, Launcher launcher, BuildListener lis | |
HttpPost httpPost = new HttpPost("/api/builds.json"); | ||
FileBody fileBody = new FileBody(file); | ||
|
||
MultipartEntity entity = new MultipartEntity(); | ||
String notes = ""; | ||
if (sendSCMchanges) { | ||
ChangeLogSet changeSet = build.getChangeSet(); | ||
if (changeSet.isEmptySet()) { | ||
notes = vars.expand(buildNotes); | ||
listener.getLogger().println("No changeset found, sending default build notes to TestFlight"); | ||
} | ||
else { | ||
for (Object changelog : changeSet.getItems()) { | ||
notes = notes + ((ChangeLogSet.Entry)changelog).getMsg() + "\n"; | ||
} | ||
} | ||
} | ||
else | ||
notes = vars.expand(buildNotes); | ||
|
||
MultipartEntity entity = new MultipartEntity(); | ||
entity.addPart("api_token", new StringBody(apiToken)); | ||
entity.addPart("team_token", new StringBody(teamToken)); | ||
entity.addPart("notes", new StringBody(vars.expand(buildNotes))); | ||
//entity.addPart("notes", new StringBody(vars.expand(buildNotes))); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remember to remove code you have commented out |
||
// Add the notes from the SCM changelogs | ||
entity.addPart("notes", new StringBody(notes)); | ||
listener.getLogger().println("Notes to send to TestFlight: " + notes); | ||
entity.addPart("file", fileBody); | ||
|
||
if (!StringUtils.isEmpty(dsymPath)) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe initialize the variable with default build notes first, like this:
Then the logic below can be simplified a bit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, you're right