Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #107 from cjo9900/JENKINS-15160
Jenkins 15160
- Loading branch information
Showing
5 changed files
with
279 additions
and
7 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
30 changes: 30 additions & 0 deletions
30
src/main/resources/hudson/plugins/git/GitRevisionBuildParameters/config.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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<!-- | ||
The MIT License | ||
Copyright (c) 2004-2012, Chris Johnson | ||
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. | ||
--> | ||
|
||
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form"> | ||
<f:entry field="combineQueuedCommits" | ||
title="${%Combine Queued git hashes}"> | ||
<f:checkbox /> | ||
</f:entry> | ||
</j:jelly> |
6 changes: 6 additions & 0 deletions
6
...in/resources/hudson/plugins/git/GitRevisionBuildParameters/help-combineQueuedCommits.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,6 @@ | ||
<div> | ||
This checkbox cause the all revisions to be be ingnored apart from the last one if a build is already in the queue.<br/> | ||
Does not combine entries with builds of manually started downstream job that are queued. (Ones that do no have a git hash attached to them)<br/> | ||
Warning: There is no consideration for multiple branches, or any other behaviour, | ||
it is your responsibility to make sure that the hashes provided come from the same branch. | ||
</div> |
163 changes: 163 additions & 0 deletions
163
src/test/java/hudson/plugins/git/RevisionParameterActionTest.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,163 @@ | ||
/* | ||
* The MIT License | ||
* | ||
* Copyright (c) 2012, Chris Johnson | ||
* | ||
* 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 hudson.plugins.git; | ||
|
||
import hudson.model.FreeStyleProject; | ||
import org.jvnet.hudson.test.HudsonTestCase; | ||
|
||
import java.util.concurrent.Future; | ||
import java.util.Collections; | ||
|
||
/** | ||
* Tests for {@link RevisionParameterAction} | ||
* | ||
* @author Chris Johnson | ||
*/ | ||
public class RevisionParameterActionTest extends HudsonTestCase { | ||
|
||
/** | ||
* Test covering the behaviour after 1.1.26 where passing different revision | ||
* actions to a job in the queue creates seperate builds | ||
*/ | ||
public void testCombiningScheduling() throws Exception { | ||
|
||
FreeStyleProject fs = createFreeStyleProject("freestyle"); | ||
|
||
// scheduleBuild2 returns null if request is combined into an existing item. (no new item added to queue) | ||
Future b1 = fs.scheduleBuild2(20, null, Collections.singletonList(new RevisionParameterAction("DEADBEEF"))); | ||
Future b2 = fs.scheduleBuild2(20, null, Collections.singletonList(new RevisionParameterAction("FREED456"))); | ||
|
||
// Check that we have the correct futures. | ||
assertNotNull(b1); | ||
assertNotNull(b2); | ||
|
||
// Check that only one build occured | ||
waitUntilNoActivity(); | ||
assertEquals(fs.getBuilds().size(),2); | ||
} | ||
/** test when existing revision is already in the queue | ||
*/ | ||
public void testCombiningScheduling2() throws Exception { | ||
|
||
FreeStyleProject fs = createFreeStyleProject("freestyle"); | ||
|
||
// scheduleBuild2 returns null if request is combined into an existing item. (no new item added to queue) | ||
Future b1 = fs.scheduleBuild2(20, null, Collections.singletonList(new RevisionParameterAction("DEADBEEF"))); | ||
Future b2 = fs.scheduleBuild2(20, null, Collections.singletonList(new RevisionParameterAction("DEADBEEF"))); | ||
|
||
// Check that we have the correct futures. | ||
assertNotNull(b1); | ||
assertNull(b2); | ||
|
||
// Check that only one build occured | ||
waitUntilNoActivity(); | ||
assertEquals(fs.getBuilds().size(),1); | ||
} | ||
/** test when there is no revision on the item in the queue | ||
*/ | ||
public void testCombiningScheduling3() throws Exception { | ||
|
||
FreeStyleProject fs = createFreeStyleProject("freestyle"); | ||
|
||
// scheduleBuild2 returns null if request is combined into an existing item. (no new item added to queue) | ||
Future b1 = fs.scheduleBuild2(20); | ||
Future b2 = fs.scheduleBuild2(20, null, Collections.singletonList(new RevisionParameterAction("DEADBEEF"))); | ||
|
||
// Check that we have the correct futures. | ||
assertNotNull(b1); | ||
assertNotNull(b2); | ||
|
||
// Check that only one build occured | ||
waitUntilNoActivity(); | ||
assertEquals(fs.getBuilds().size(),2); | ||
} | ||
|
||
/** test when a different revision is already in the queue, and combine requests is required. | ||
*/ | ||
public void testCombiningScheduling4() throws Exception { | ||
|
||
FreeStyleProject fs = createFreeStyleProject("freestyle"); | ||
|
||
// scheduleBuild2 returns null if request is combined into an existing item. (no new item added to queue) | ||
Future b1 = fs.scheduleBuild2(20, null, Collections.singletonList(new RevisionParameterAction("DEADBEEF", true))); | ||
Future b2 = fs.scheduleBuild2(20, null, Collections.singletonList(new RevisionParameterAction("FFEEFFEE", true))); | ||
|
||
// Check that we have the correct futures. | ||
assertNotNull(b1); | ||
assertNull(b2); | ||
|
||
// Check that only one build occured | ||
waitUntilNoActivity(); | ||
assertEquals(fs.getBuilds().size(),1); | ||
|
||
//check that the correct commit id is present in build | ||
assertEquals(fs.getBuilds().get(0).getAction(RevisionParameterAction.class).commit, "FFEEFFEE"); | ||
|
||
} | ||
|
||
/** test when a same revision is already in the queue, and combine requests is required. | ||
*/ | ||
public void testCombiningScheduling5() throws Exception { | ||
|
||
FreeStyleProject fs = createFreeStyleProject("freestyle"); | ||
|
||
// scheduleBuild2 returns null if request is combined into an existing item. (no new item added to queue) | ||
Future b1 = fs.scheduleBuild2(20, null, Collections.singletonList(new RevisionParameterAction("DEADBEEF", true))); | ||
Future b2 = fs.scheduleBuild2(20, null, Collections.singletonList(new RevisionParameterAction("DEADBEEF", true))); | ||
|
||
// Check that we have the correct futures. | ||
assertNotNull(b1); | ||
assertNull(b2); | ||
|
||
// Check that only one build occured | ||
waitUntilNoActivity(); | ||
assertEquals(fs.getBuilds().size(),1); | ||
|
||
//check that the correct commit id is present in build | ||
assertEquals(fs.getBuilds().get(0).getAction(RevisionParameterAction.class).commit, "DEADBEEF"); | ||
} | ||
|
||
/** test when a job already in the queue with no revision(manually started), and combine requests is required. | ||
*/ | ||
public void testCombiningScheduling6() throws Exception { | ||
|
||
FreeStyleProject fs = createFreeStyleProject("freestyle"); | ||
|
||
// scheduleBuild2 returns null if request is combined into an existing item. (no new item added to queue) | ||
Future b1 = fs.scheduleBuild2(20); | ||
Future b2 = fs.scheduleBuild2(20, null, Collections.singletonList(new RevisionParameterAction("DEADBEEF", true))); | ||
|
||
// Check that we have the correct futures. | ||
assertNotNull(b1); | ||
assertNotNull(b2); | ||
|
||
// Check that only one build occured | ||
waitUntilNoActivity(); | ||
assertEquals(fs.getBuilds().size(),2); | ||
|
||
//check that the correct commit id is present in 2nd build | ||
// list is reversed indexed so first item is latest build | ||
assertEquals(fs.getBuilds().get(0).getAction(RevisionParameterAction.class).commit, "DEADBEEF"); | ||
} | ||
} |