forked from jenkinsci/git-plugin
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[JENKINS-4162] Optionally report the most recent commit as the change…
…log of a new build (jenkinsci#1565) * Add files via upload * code for gui * trait file * gitscm changes * testing for new trait behavior * null check time * update to proper version number Co-authored-by: UltimateGeek <[email protected]> * Update FirstBuildChangelogTrait Removed improper CloudBees copyright documentation, updated @param for the constructor * Format new files with spotless:apply Use line termination that is consistent with the other files in the repository. Use import ordering as defined by spotless. * Remove trailing space characters * Changed equals to use proper equals method * Changed equals to use proper equals method * Changed equals to use proper equals method * changed to compatible equal * Fix Mark's poor code review * Use leading lower case letter for the symbol Jenkins symbol names consistently start with a lower case letter. * Use sentence case for display name * Set API release to 5.3.0 * removed groovy and checkbox * Update to documentation and applying spotless * Pushing documentation image * Undo spotless changes - not ready for spotless * Reduce doc diffs * Use Unix file format for help * Jenkins Pipeline symbols start with a lower case letter * Remove blank line from doc example * First build changelog reports most recent commit as changelog The new extension reports the most recent commit as the changelog. It does not report the changes from a base branch, because there is no reliable method to identify the base branch from command line git. Also adjusts capitalization to be consistent with other parts of the documentation. * Format new example same as prior examples. * Clarify first build option help and docs * Remove comment as suggested by reviewer --------- Co-authored-by: Derek Inskeep <[email protected]> Co-authored-by: UltimateGeek <[email protected]> Co-authored-by: Mark Waite <[email protected]> Co-authored-by: Derek Inskeep <[email protected]>
- Loading branch information
1 parent
a2b54b1
commit 25ca71b
Showing
7 changed files
with
175 additions
and
3 deletions.
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
76 changes: 76 additions & 0 deletions
76
src/main/java/hudson/plugins/git/extensions/impl/FirstBuildChangelog.java
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 |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package hudson.plugins.git.extensions.impl; | ||
|
||
import hudson.Extension; | ||
import hudson.plugins.git.extensions.GitSCMExtension; | ||
import hudson.plugins.git.extensions.GitSCMExtensionDescriptor; | ||
import java.util.Objects; | ||
import org.jenkinsci.Symbol; | ||
import org.kohsuke.stapler.DataBoundConstructor; | ||
import org.kohsuke.stapler.DataBoundSetter; | ||
|
||
/** | ||
* First Build generates a changelog. | ||
* | ||
* @author Derek Inskeep | ||
*/ | ||
public class FirstBuildChangelog extends GitSCMExtension { | ||
private boolean makeChangelog; | ||
|
||
@DataBoundConstructor | ||
public FirstBuildChangelog() { | ||
makeChangelog = true; | ||
} | ||
|
||
public boolean isMakeChangelog() { | ||
return makeChangelog; | ||
} | ||
|
||
@DataBoundSetter | ||
public void setMakeChangelog(boolean makeChangelog) { | ||
this.makeChangelog = makeChangelog; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) { | ||
return true; | ||
} | ||
if (o == null || getClass() != o.getClass()) { | ||
return false; | ||
} | ||
FirstBuildChangelog that = (FirstBuildChangelog) o; | ||
return makeChangelog == that.makeChangelog; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public int hashCode() { | ||
return Objects.hash(makeChangelog); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public String toString() { | ||
return "FirstBuildChangelog{" + "makeChangelog=" + makeChangelog + '}'; | ||
} | ||
|
||
@Extension | ||
@Symbol("firstBuildChangelog") | ||
public static class DescriptorImpl extends GitSCMExtensionDescriptor { | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public String getDisplayName() { | ||
return "First build changelog"; | ||
} | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
src/main/java/jenkins/plugins/git/traits/FirstBuildChangelogTrait.java
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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package jenkins.plugins.git.traits; | ||
|
||
import edu.umd.cs.findbugs.annotations.CheckForNull; | ||
import hudson.Extension; | ||
import hudson.plugins.git.extensions.impl.FirstBuildChangelog; | ||
import jenkins.scm.api.trait.SCMSourceTrait; | ||
import org.jenkinsci.Symbol; | ||
import org.kohsuke.stapler.DataBoundConstructor; | ||
|
||
/** | ||
* Exposes {@link FirstBuildChangelog} as a {@link SCMSourceTrait}. | ||
* | ||
* @since 5.3.0 | ||
*/ | ||
public class FirstBuildChangelogTrait extends GitSCMExtensionTrait<FirstBuildChangelog> { | ||
|
||
/** | ||
* @deprecated Use constructor that accepts extension instead. | ||
*/ | ||
@Deprecated | ||
public FirstBuildChangelogTrait() { | ||
this(null); | ||
} | ||
|
||
/** | ||
* Stapler constructor. | ||
* | ||
* @param extension the option to force first build to have a non-empty changelog. | ||
*/ | ||
@DataBoundConstructor | ||
public FirstBuildChangelogTrait(@CheckForNull FirstBuildChangelog extension) { | ||
super(extension == null ? new FirstBuildChangelog() : extension); | ||
} | ||
|
||
/** | ||
* Our {@link hudson.model.Descriptor} | ||
*/ | ||
@Extension | ||
@Symbol("firstBuildChangelog") | ||
public static class DescriptorImpl extends GitSCMExtensionTraitDescriptor { | ||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public String getDisplayName() { | ||
return "First Build Changelog"; | ||
} | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
src/main/resources/hudson/plugins/git/extensions/impl/FirstBuildChangelog/help.html
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<div> | ||
First builds will populate the changelog with the latest commit, if any, to allow Pipelines to check and test for file changes. | ||
By default, no changelog is generated for the first build because the first build has no predecessor build for comparison. | ||
When the first build changelog option is enabled, the most recent commit on the branch will be used as the changelog of the first build. | ||
</div> |
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