-
-
Notifications
You must be signed in to change notification settings - Fork 8.8k
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
[JENKINS-24141] Pull ChangeLogSet-related logic out of AbstractBuild #2730
Merged
Merged
Changes from 18 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
bd84482
[WIP JENKINS-24141] First work on abstracting out changelogs
abayer 61acefc
Switch to a mixin approach
abayer d7d4a82
Minor cleanup, fixing AbstractBuild.getChangeSets()
abayer 285e83a
Merge branch 'master' into jenkins-24141
abayer 8ff1dd6
Add SCM.buildEnvVars(Run,Map<String,String>)
abayer 7fe3a4a
Initial work on DependencyGraph
abayer 569c990
Merge branch 'master' into jenkins-24141
abayer 4f3172c
Normalize versioning because that was unneeded
abayer e4b84a2
Revert "Initial work on DependencyGraph"
abayer e6f6064
Code review responses
abayer 3913680
Rework to solo RunWithSCM interface
abayer 977f922
Refactor for supporting on-demand calculation of culprits
abayer 28dce4c
Get rid of asRun().
abayer 31bc417
Review comments.
abayer 66460f9
Get rid of isBuilding() check on previous build's culprits.
abayer 99baf7a
Forgot a bit of javadoc
abayer aa5ff54
Forgot to remove SCMTriggerItem everywhere in View
abayer 71a4614
Javadoc cleanup
abayer b6e1ae5
Adding a @since TODO for Job.doRssChangelog
abayer 914963c
Get rid of superfluous Queue.Task/Executable
abayer 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
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
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 |
---|---|---|
|
@@ -28,6 +28,7 @@ | |
import hudson.EnvVars; | ||
import hudson.Extension; | ||
import hudson.ExtensionPoint; | ||
import hudson.FeedAdapter; | ||
import hudson.PermalinkList; | ||
import hudson.Util; | ||
import hudson.cli.declarative.CLIResolver; | ||
|
@@ -36,6 +37,8 @@ | |
import hudson.model.Fingerprint.RangeSet; | ||
import hudson.model.PermalinkProjectAction.Permalink; | ||
import hudson.model.listeners.ItemListener; | ||
import hudson.scm.ChangeLogSet; | ||
import hudson.scm.SCM; | ||
import hudson.search.QuickSilver; | ||
import hudson.search.SearchIndex; | ||
import hudson.search.SearchIndexBuilder; | ||
|
@@ -83,12 +86,14 @@ | |
import jenkins.model.BuildDiscarderProperty; | ||
import jenkins.model.DirectlyModifiableTopLevelItemGroup; | ||
import jenkins.model.Jenkins; | ||
import jenkins.model.JenkinsLocationConfiguration; | ||
import jenkins.model.ModelObjectWithChildren; | ||
import jenkins.model.ProjectNamingStrategy; | ||
import jenkins.model.RunIdMigrator; | ||
import jenkins.model.lazy.LazyBuildMixIn; | ||
import jenkins.scm.RunWithSCM; | ||
import jenkins.security.HexStringConfidentialKey; | ||
import jenkins.util.io.OnMaster; | ||
import jenkins.triggers.SCMTriggerItem; | ||
import net.sf.json.JSONException; | ||
import net.sf.json.JSONObject; | ||
import org.apache.commons.io.FileUtils; | ||
|
@@ -1042,7 +1047,82 @@ public PermalinkList getPermalinks() { | |
} | ||
return permalinks; | ||
} | ||
|
||
|
||
/** | ||
* RSS feed for changes in this project. | ||
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. Should note that 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. Will do. |
||
*/ | ||
public void doRssChangelog(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException { | ||
class FeedItem { | ||
ChangeLogSet.Entry e; | ||
int idx; | ||
|
||
public FeedItem(ChangeLogSet.Entry e, int idx) { | ||
this.e = e; | ||
this.idx = idx; | ||
} | ||
|
||
Run<?, ?> getBuild() { | ||
return e.getParent().build; | ||
} | ||
} | ||
|
||
List<FeedItem> entries = new ArrayList<FeedItem>(); | ||
String scmDisplayName = ""; | ||
if (this instanceof SCMTriggerItem) { | ||
SCMTriggerItem scmItem = (SCMTriggerItem) this; | ||
List<String> scmNames = new ArrayList<>(); | ||
for (SCM s : scmItem.getSCMs()) { | ||
scmNames.add(s.getDescriptor().getDisplayName()); | ||
} | ||
scmDisplayName = " " + Util.join(scmNames, ", "); | ||
} | ||
|
||
for (RunT r = getLastBuild(); r != null; r = r.getPreviousBuild()) { | ||
int idx = 0; | ||
if (r instanceof RunWithSCM) { | ||
for (ChangeLogSet<? extends ChangeLogSet.Entry> c : ((RunWithSCM<?,?>) r).getChangeSets()) { | ||
for (ChangeLogSet.Entry e : c) { | ||
entries.add(new FeedItem(e, idx++)); | ||
} | ||
} | ||
} | ||
} | ||
RSS.forwardToRss( | ||
getDisplayName() + scmDisplayName + " changes", | ||
getUrl() + "changes", | ||
entries, new FeedAdapter<FeedItem>() { | ||
public String getEntryTitle(FeedItem item) { | ||
return "#" + item.getBuild().number + ' ' + item.e.getMsg() + " (" + item.e.getAuthor() + ")"; | ||
} | ||
|
||
public String getEntryUrl(FeedItem item) { | ||
return item.getBuild().getUrl() + "changes#detail" + item.idx; | ||
} | ||
|
||
public String getEntryID(FeedItem item) { | ||
return getEntryUrl(item); | ||
} | ||
|
||
public String getEntryDescription(FeedItem item) { | ||
StringBuilder buf = new StringBuilder(); | ||
for (String path : item.e.getAffectedPaths()) | ||
buf.append(path).append('\n'); | ||
return buf.toString(); | ||
} | ||
|
||
public Calendar getEntryTimestamp(FeedItem item) { | ||
return item.getBuild().getTimestamp(); | ||
} | ||
|
||
public String getEntryAuthor(FeedItem entry) { | ||
return JenkinsLocationConfiguration.get().getAdminAddress(); | ||
} | ||
}, | ||
req, rsp); | ||
} | ||
|
||
|
||
|
||
@Override public ContextMenu doChildrenContextMenu(StaplerRequest request, StaplerResponse response) throws Exception { | ||
// not sure what would be really useful here. This needs more thoughts. | ||
// for the time being, I'm starting with permalinks | ||
|
Oops, something went wrong.
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.
If this implements caching, where does it consider parallel builds that complete out of order?
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.
shrug? It's the same logic as had previously existed for populating
AbstractBuild.culprits
, just organized differently.