Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'JENKINS-21063' of https://github.com/andham/m2release-p…
…lugin into andham-JENKINS-21063
- Loading branch information
Showing
10 changed files
with
217 additions
and
39 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
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
19 changes: 12 additions & 7 deletions
19
src/main/resources/org/jvnet/hudson/plugins/m2release/M2ReleaseBadgeAction/badge.jelly
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 |
---|---|---|
@@ -1,8 +1,13 @@ | ||
<j:jelly xmlns:j="jelly:core"> | ||
<j:if test="${it.isDryRun()}"> | ||
<img width="16" height="16" title="${it.tooltipText}" src="${rootURL}/plugin/m2release/img/new-package.png"/> | ||
</j:if> | ||
<j:if test="${!it.isDryRun()}"> | ||
<img width="16" height="16" title="${it.tooltipText}" src="${imagesURL}/16x16/package.png"/> | ||
</j:if> | ||
</j:jelly> | ||
<j:choose> | ||
<j:when test="${it.isFailedBuild()}"> | ||
<img width="16" height="16" title="${it.tooltipText}" src="${rootURL}/plugin/m2release/img/releasebadge-failure.png"/> | ||
</j:when> | ||
<j:when test="${it.isDryRun()}"> | ||
<img width="16" height="16" title="${it.tooltipText}" src="${rootURL}/plugin/m2release/img/releasebadge-dryrun.png"/> | ||
</j:when> | ||
<j:otherwise> | ||
<img width="16" height="16" title="${it.tooltipText}" src="${rootURL}/plugin/m2release/img/releasebadge.png"/> | ||
</j:otherwise> | ||
</j:choose> | ||
</j:jelly> |
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
118 changes: 118 additions & 0 deletions
118
src/test/java/org/jvnet/hudson/plugins/m2release/M2ReleaseBadgeActionTest.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,118 @@ | ||
/* | ||
* The MIT License | ||
* | ||
* Copyright (c) 2011, Dominik Bartholdi | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
*/ | ||
package org.jvnet.hudson.plugins.m2release; | ||
|
||
import java.io.IOException; | ||
|
||
import hudson.Launcher; | ||
import hudson.maven.MavenModuleSet; | ||
import hudson.maven.MavenModuleSetBuild; | ||
import hudson.model.BuildListener; | ||
import hudson.model.Result; | ||
import hudson.model.AbstractBuild; | ||
import hudson.tasks.Builder; | ||
import hudson.tasks.Maven.MavenInstallation; | ||
|
||
import org.jvnet.hudson.plugins.m2release.M2ReleaseBuildWrapper.DescriptorImpl; | ||
import org.jvnet.hudson.test.ExtractResourceSCM; | ||
import org.jvnet.hudson.test.HudsonTestCase; | ||
|
||
public class M2ReleaseBadgeActionTest extends HudsonTestCase { | ||
|
||
public void testBadgeForSuccessfulDryRunRelease() throws Exception { | ||
MavenInstallation mavenInstallation = configureDefaultMaven(); | ||
final MavenModuleSetBuild build = | ||
runDryRunRelease("maven2-project.zip", "pom.xml", mavenInstallation, Result.SUCCESS); | ||
M2ReleaseBadgeAction badge = build.getAction(M2ReleaseBadgeAction.class); | ||
assertTrue("Badge is not marked as dryRun", badge.isDryRun()); | ||
assertFalse("Badge should not have been marked as failed release", badge.isFailedBuild()); | ||
assertEquals("1.0", badge.getVersionNumber()); | ||
} | ||
|
||
public void testBadgeForFailedDryRunRelease() throws Exception { | ||
MavenInstallation mavenInstallation = configureMaven3(); | ||
final MavenModuleSetBuild build = | ||
runDryRunRelease("maven3-failing-project.zip", "pom.xml", mavenInstallation, Result.FAILURE); | ||
M2ReleaseBadgeAction badge = build.getAction(M2ReleaseBadgeAction.class); | ||
assertTrue("Badge is not marked as dryRun", badge.isDryRun()); | ||
assertTrue("Badge should have been marked as failed release", badge.isFailedBuild()); | ||
assertEquals("1.0", badge.getVersionNumber()); | ||
} | ||
|
||
public void testBadgeForFailedPostBuildStepRelease() throws Exception { | ||
MavenInstallation mavenInstallation = configureMaven3(); | ||
final MavenModuleSetBuild build = | ||
runDryRunReleaseWithFailingPostStep("maven3-failing-project.zip", "pom.xml", mavenInstallation, Result.FAILURE); | ||
M2ReleaseBadgeAction badge = build.getAction(M2ReleaseBadgeAction.class); | ||
assertTrue("Badge should have been marked as failed release", badge.isFailedBuild()); | ||
assertEquals("1.0", badge.getVersionNumber()); | ||
} | ||
|
||
private MavenModuleSetBuild runDryRunRelease(String projectZip, String unpackedPom, | ||
MavenInstallation mavenInstallation, Result expectedResult) | ||
throws Exception { | ||
return runDryRunRelease(projectZip, unpackedPom, mavenInstallation, expectedResult, null); | ||
} | ||
|
||
private MavenModuleSetBuild runDryRunReleaseWithFailingPostStep(String projectZip, String unpackedPom, | ||
MavenInstallation mavenInstallation, Result expectedResult) | ||
throws Exception { | ||
Builder failingPostStep = new FailingBuilder(); | ||
return runDryRunRelease(projectZip, unpackedPom, mavenInstallation, expectedResult, failingPostStep); | ||
} | ||
|
||
private MavenModuleSetBuild runDryRunRelease(String projectZip, String unpackedPom, | ||
MavenInstallation mavenInstallation, Result expectedResult, Builder postStepBuilder) | ||
throws Exception { | ||
MavenModuleSet m = createMavenProject(); | ||
m.setRootPOM(unpackedPom); | ||
m.setMaven(mavenInstallation.getName()); | ||
m.setScm(new ExtractResourceSCM(getClass().getResource(projectZip))); | ||
m.setGoals("dummygoal"); // non-dryRun build would fail with this goal | ||
|
||
final M2ReleaseBuildWrapper wrapper = | ||
new M2ReleaseBuildWrapper(DescriptorImpl.DEFAULT_RELEASE_GOALS, DescriptorImpl.DEFAULT_DRYRUN_GOALS, | ||
false, false, false, "ENV", "USERENV", "PWDENV", | ||
DescriptorImpl.DEFAULT_NUMBER_OF_RELEASE_BUILDS_TO_KEEP); | ||
M2ReleaseArgumentsAction args = new M2ReleaseArgumentsAction(); | ||
args.setReleaseVersion("1.0"); | ||
args.setDevelopmentVersion("1.1-SNAPSHOT"); | ||
args.setDryRun(true); | ||
m.getBuildWrappersList().add(wrapper); | ||
|
||
if (postStepBuilder != null) { | ||
m.getPostbuilders().add(postStepBuilder); | ||
} | ||
|
||
return assertBuildStatus(expectedResult, m.scheduleBuild2(0, new ReleaseCause(), args).get()); | ||
} | ||
|
||
private static class FailingBuilder extends Builder { | ||
@Override | ||
public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) | ||
throws InterruptedException, IOException { | ||
return false; // failing build | ||
} | ||
} | ||
} |
Binary file added
BIN
+1.17 KB
src/test/resources/org/jvnet/hudson/plugins/m2release/maven3-failing-project.zip
Binary file not shown.