Skip to content
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

Add ability for submodule release (diff cleanup) #11

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>1.442</version>
<version>1.488</version>
</parent>

<name>Jenkins Maven Release Plug-in Plug-in</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,14 @@ public class M2ReleaseAction implements PermalinkProjectAction {
private boolean selectCustomScmTag = false;
private boolean selectAppendHudsonUsername;
private boolean selectScmCredentials;
private boolean selectSubmoduleRelease;

public M2ReleaseAction(MavenModuleSet project, boolean selectCustomScmCommentPrefix, boolean selectAppendHudsonUsername, boolean selectScmCredentials) {
public M2ReleaseAction(MavenModuleSet project, boolean selectCustomScmCommentPrefix, boolean selectAppendHudsonUsername, boolean selectScmCredentials, boolean selectSubmoduleRelease) {
this.project = project;
this.selectCustomScmCommentPrefix = selectCustomScmCommentPrefix;
this.selectAppendHudsonUsername = selectAppendHudsonUsername;
this.selectScmCredentials = selectScmCredentials;
this.selectSubmoduleRelease = selectSubmoduleRelease;
if (getRootModule() == null) {
// if the root module is not available, the user should be informed
// about the stuff we are not able to compute
Expand Down Expand Up @@ -133,6 +135,14 @@ public void setSelectAppendHudsonUsername(boolean selectAppendHudsonUsername) {
this.selectAppendHudsonUsername = selectAppendHudsonUsername;
}

public boolean isSelectSubmoduleRelease() {
return selectSubmoduleRelease;
}

public void setSelectSubmoduleRelease(boolean selectSubmoduleRelease) {
this.selectSubmoduleRelease = selectSubmoduleRelease;
}

public boolean isSelectCustomScmTag() {
return selectCustomScmTag;
}
Expand Down Expand Up @@ -217,6 +227,8 @@ public void doSubmit(StaplerRequest req, StaplerResponse resp) throws IOExceptio
final String scmCommentPrefix = specifyScmCommentPrefix ? getString("scmCommentPrefix", httpParams) : null; //$NON-NLS-1$
final boolean specifyScmTag = httpParams.containsKey("specifyScmTag"); //$NON-NLS-1$
final String scmTag = specifyScmTag ? getString("scmTag", httpParams) : null; //$NON-NLS-1$
final boolean submoduleRelease = httpParams.containsKey("submoduleRelease"); //$NON-NLS-1$
final String submodules = submoduleRelease ? getString("submodules", httpParams) : null; //$NON-NLS-1$

final boolean appendHusonUserName = specifyScmCommentPrefix && httpParams.containsKey("appendHudsonUserName"); //$NON-NLS-1$
final boolean isDryRun = httpParams.containsKey("isDryRun"); //$NON-NLS-1$
Expand Down Expand Up @@ -278,6 +290,7 @@ public void doSubmit(StaplerRequest req, StaplerResponse resp) throws IOExceptio
arguments.setScmUsername(scmUsername);
arguments.setScmPassword(scmPassword);
arguments.setScmTagName(scmTag);
arguments.setSubmodules(submodules);
arguments.setScmCommentPrefix(scmCommentPrefix);
arguments.setAppendHusonUserName(appendHusonUserName);
arguments.setHudsonUserName(Hudson.getAuthentication().getName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public class M2ReleaseArgumentsAction implements Action {
private transient String scmPassword;
private transient String scmCommentPrefix;
private String scmTagName;
private String submodules;

private transient boolean appendHusonUserName;
private transient String hudsonUserName;
Expand Down Expand Up @@ -186,4 +187,12 @@ public void setHudsonUserName(String hudsonUserName) {
this.hudsonUserName = hudsonUserName;
}

public String getSubmodules() {
return submodules;
}

public void setSubmodules(String submodules) {
this.submodules = submodules;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ public class M2ReleaseBuildWrapper extends BuildWrapper {
public boolean selectCustomScmCommentPrefix = DescriptorImpl.DEFAULT_SELECT_CUSTOM_SCM_COMMENT_PREFIX;
public boolean selectAppendHudsonUsername = DescriptorImpl.DEFAULT_SELECT_APPEND_HUDSON_USERNAME;
public boolean selectScmCredentials = DescriptorImpl.DEFAULT_SELECT_SCM_CREDENTIALS;
public boolean selectSubmodules = DescriptorImpl.DEFAULT_SELECT_SUBMODULES;

public int numberOfReleaseBuildsToKeep = DescriptorImpl.DEFAULT_NUMBER_OF_RELEASE_BUILDS_TO_KEEP;

Expand Down Expand Up @@ -163,6 +164,10 @@ public void buildEnvVars(Map<String, String> env) {
if (args.getScmTagName() != null) {
buildGoals.append("-Dtag=").append(args.getScmTagName()).append(' ');
}

if (args.getSubmodules() != null) {
buildGoals.append("--projects ").append(args.getSubmodules()).append(' ');
}

if (args.isDryRun()) {
buildGoals.append(getDryRunGoals());
Expand Down Expand Up @@ -373,7 +378,7 @@ private Object readResolve() {

@Override
public Action getProjectAction(@SuppressWarnings("rawtypes") AbstractProject job) {
return new M2ReleaseAction((MavenModuleSet) job, selectCustomScmCommentPrefix, selectAppendHudsonUsername, selectScmCredentials);
return new M2ReleaseAction((MavenModuleSet) job, selectCustomScmCommentPrefix, selectAppendHudsonUsername, selectScmCredentials, selectSubmodules);
}

/**
Expand Down Expand Up @@ -465,6 +470,7 @@ public static class DescriptorImpl extends BuildWrapperDescriptor {
public static final boolean DEFAULT_SELECT_CUSTOM_SCM_COMMENT_PREFIX = false;
public static final boolean DEFAULT_SELECT_APPEND_HUDSON_USERNAME = false;
public static final boolean DEFAULT_SELECT_SCM_CREDENTIALS = false;
public static final boolean DEFAULT_SELECT_SUBMODULES = false;

public static final int DEFAULT_NUMBER_OF_RELEASE_BUILDS_TO_KEEP = 1;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@
<f:textbox name="scmTag" value="${it.computeScmTag()}" />
</f:entry>
</f:optionalBlock>

<f:optionalBlock name="submoduleRelease" title="Release Specific Submodules" checked="${it.selectSubmoduleRelease}" help="/plugin/m2release/help-actionRelease-specifySubmodule.html">
<f:entry title="Submodules">
<f:textbox name="submodules" value="" />
</f:entry>
</f:optionalBlock>

<j:if test="${it.nexusSupportEnabled}">
<f:section title="Nexus Pro Support">
Expand Down
6 changes: 6 additions & 0 deletions src/main/webapp/help-actionRelease-specifySubmodule.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<div>
Enable this option to manually select which sub modules you want to release. If you want to release multiple modules at once, separate them with ','.
By default all modules are released.
<p>Example:<p/>
<p>org.example.group:artifact1,org.example.group:artifact2<p/>
</div>