Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[JENKINS-21063] Badge now retrieves dryRun, version, and failedBuild …
…info from build instead of storing it. As a side effect, variables in M2ReleaseBadgeAction were removed which will affect builds persisted with older versions of the plugin. Also, required version of Jenkins was bumped to 1.509.3. Signed-off-by: Anders Hammar <anders@hammar.net>
- Loading branch information
Showing
6 changed files
with
115 additions
and
45 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
2 changes: 1 addition & 1 deletion
2
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
78 changes: 78 additions & 0 deletions
78
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,78 @@ | ||
/* | ||
* 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 hudson.maven.MavenModuleSet; | ||
import hudson.maven.MavenModuleSetBuild; | ||
import hudson.model.Result; | ||
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.isFailedRelease()); | ||
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.isFailedRelease()); | ||
assertEquals("1.0", badge.getVersionNumber()); | ||
} | ||
|
||
private MavenModuleSetBuild runDryRunRelease(String projectZip, String unpackedPom, | ||
MavenInstallation mavenInstallation, Result expectedResult) | ||
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); | ||
|
||
return assertBuildStatus(expectedResult, m.scheduleBuild2(0, new ReleaseCause(), args).get()); | ||
} | ||
} |
Binary file added
BIN
+1.17 KB
src/test/resources/org/jvnet/hudson/plugins/m2release/maven3-failing-project.zip
Binary file not shown.