diff --git a/pom.xml b/pom.xml
index 495376ed..55a26fc8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
org.jenkins-ci.plugins
plugin
- 2.17
+ 2.29
promoted-builds
@@ -12,10 +12,10 @@
hpi
Jenkins promoted builds plugin
- http://wiki.jenkins-ci.org/display/JENKINS/Promoted+Builds+Plugin
+ https://wiki.jenkins-ci.org/display/JENKINS/Promoted+Builds+Plugin
- 1.565
+ 1.609.3
6
@@ -48,34 +48,15 @@
-
-
- jenkins-releases
- http://repo.jenkins-ci.org/releases/
-
- true
-
-
- false
-
-
repo.jenkins-ci.org
- http://repo.jenkins-ci.org/public/
-
- true
-
-
- false
-
+ https://repo.jenkins-ci.org/public/
-
-
repo.jenkins-ci.org
- http://repo.jenkins-ci.org/public/
+ https://repo.jenkins-ci.org/public/
@@ -83,7 +64,7 @@
org.jenkins-ci.main
maven-plugin
- 2.0
+ 2.13
com.sonyericsson.hudson.plugins.rebuild
@@ -106,7 +87,7 @@
org.jenkins-ci.plugins
token-macro
- 1.10
+ 1.12.1
true
@@ -124,7 +105,7 @@
org.jenkins-ci.plugins
script-security
- 1.16
+ 1.26
org.jvnet.hudson
@@ -135,19 +116,19 @@
org.jenkins-ci.plugins
parameterized-trigger
- 2.30
+ 2.33
test
org.jenkins-ci.plugins
matrix-auth
- 1.0
+ 1.6
test
org.jenkins-ci.plugins
matrix-project
- 1.0
+ 1.11
test
diff --git a/src/main/java/hudson/plugins/promoted_builds/JobPropertyImpl.java b/src/main/java/hudson/plugins/promoted_builds/JobPropertyImpl.java
index f3ac59d2..5413d0ce 100644
--- a/src/main/java/hudson/plugins/promoted_builds/JobPropertyImpl.java
+++ b/src/main/java/hudson/plugins/promoted_builds/JobPropertyImpl.java
@@ -12,6 +12,7 @@
import java.util.logging.Level;
import java.util.logging.Logger;
+import jenkins.security.MasterToSlaveCallable;
import org.apache.commons.lang.StringUtils;
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.NoExternalUse;
@@ -35,7 +36,6 @@
import hudson.model.JobProperty;
import hudson.model.JobPropertyDescriptor;
import hudson.model.listeners.ItemListener;
-import hudson.remoting.Callable;
import hudson.util.IOUtils;
import javax.annotation.CheckForNull;
import jenkins.model.Jenkins;
@@ -305,7 +305,7 @@ public PromotionProcess createProcessFromXml(final String name, InputStream xml)
}
try {
IOUtils.copy(xml, configXml);
- PromotionProcess result = Items.whileUpdatingByXml(new Callable() {
+ PromotionProcess result = Items.whileUpdatingByXml(new MasterToSlaveCallable() {
@Override public PromotionProcess call() throws IOException {
setOwner(owner);
return getItem(name);
diff --git a/src/test/java/hudson/plugins/promoted_builds/ConfigurationDoCheckTest.java b/src/test/java/hudson/plugins/promoted_builds/ConfigurationDoCheckTest.java
index a910b3b9..9cd12411 100644
--- a/src/test/java/hudson/plugins/promoted_builds/ConfigurationDoCheckTest.java
+++ b/src/test/java/hudson/plugins/promoted_builds/ConfigurationDoCheckTest.java
@@ -4,19 +4,29 @@
import hudson.model.FreeStyleProject;
import hudson.plugins.promoted_builds.conditions.DownstreamPassCondition;
import hudson.tasks.JavadocArchiver;
-import org.jvnet.hudson.test.Bug;
-import org.jvnet.hudson.test.HudsonTestCase;
+import org.junit.Rule;
+import org.junit.Test;
+import org.jvnet.hudson.test.Issue;
+import org.jvnet.hudson.test.JenkinsRule;
+
+import static com.gargoylesoftware.htmlunit.html.HtmlFormUtil.submit;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
/**
* @author Seiji Sogabe
*/
-public class ConfigurationDoCheckTest extends HudsonTestCase {
+public class ConfigurationDoCheckTest {
+
+ @Rule
+ public JenkinsRule j = new JenkinsRule();
- @Bug(7972)
+ @Issue("JENKINS-7972")
+ @Test
public void testCheckProcessNameRequired() throws Exception {
- FreeStyleProject down = createFreeStyleProject();
+ FreeStyleProject down = j.createFreeStyleProject();
- FreeStyleProject p = createFreeStyleProject();
+ FreeStyleProject p = j.createFreeStyleProject();
JobPropertyImpl pp = new JobPropertyImpl(p);
p.addProperty(pp);
@@ -26,18 +36,20 @@ public void testCheckProcessNameRequired() throws Exception {
proc.getBuildSteps().add(new JavadocArchiver("somedir",true));
proc.icon = "star-blue";
- WebClient client = new WebClient();
+ JenkinsRule.WebClient client = j.createWebClient();
client.getOptions().setThrowExceptionOnFailingStatusCode(false);
- HtmlPage page = submit(client.getPage(p, "configure").getFormByName("config"));
+
+ HtmlPage page = (HtmlPage) submit(client.getPage(p, "configure").getFormByName("config"));
assertTrue(page.asText().contains("No name is specified"));
}
- @Bug(7972)
+ @Issue("JENKINS-7972")
+ @Test
public void testCheckInvalidProcessName() throws Exception {
- FreeStyleProject down = createFreeStyleProject();
+ FreeStyleProject down = j.createFreeStyleProject();
- FreeStyleProject p = createFreeStyleProject();
+ FreeStyleProject p = j.createFreeStyleProject();
JobPropertyImpl pp = new JobPropertyImpl(p);
p.addProperty(pp);
@@ -47,9 +59,10 @@ public void testCheckInvalidProcessName() throws Exception {
proc.getBuildSteps().add(new JavadocArchiver("somedir",true));
proc.icon = "star-blue";
- WebClient client = new WebClient();
+ JenkinsRule.WebClient client = j.createWebClient();
client.getOptions().setThrowExceptionOnFailingStatusCode(false);
- HtmlPage page = submit(client.getPage(p, "configure").getFormByName("config"));
+
+ HtmlPage page = (HtmlPage) submit(client.getPage(p, "configure").getFormByName("config"));
assertTrue(page.asText().contains("unsafe character"));
}
diff --git a/src/test/java/hudson/plugins/promoted_builds/ConfigurationRoundtripTest.java b/src/test/java/hudson/plugins/promoted_builds/ConfigurationRoundtripTest.java
index 30d14fd6..51d8c4eb 100644
--- a/src/test/java/hudson/plugins/promoted_builds/ConfigurationRoundtripTest.java
+++ b/src/test/java/hudson/plugins/promoted_builds/ConfigurationRoundtripTest.java
@@ -26,21 +26,33 @@
import hudson.model.FreeStyleProject;
import hudson.plugins.promoted_builds.conditions.DownstreamPassCondition;
import hudson.tasks.JavadocArchiver;
-import org.jvnet.hudson.test.Bug;
-import org.jvnet.hudson.test.HudsonTestCase;
+import org.junit.Rule;
+import org.junit.Test;
+import org.jvnet.hudson.test.Issue;
+import org.jvnet.hudson.test.JenkinsRule;
import org.jvnet.hudson.test.recipes.LocalData;
+import static com.gargoylesoftware.htmlunit.html.HtmlFormUtil.submit;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
/**
* @author Kohsuke Kawaguchi
*/
-public class ConfigurationRoundtripTest extends HudsonTestCase {
+public class ConfigurationRoundtripTest {
+
+ @Rule
+ public JenkinsRule j = new JenkinsRule();
+
/**
* Configuration roundtrip test to detect data loss.
*/
+ @Test
public void testRoundtrip() throws Exception {
- FreeStyleProject down = createFreeStyleProject();
+ FreeStyleProject down = j.createFreeStyleProject();
- FreeStyleProject p = createFreeStyleProject();
+ FreeStyleProject p = j.createFreeStyleProject();
JobPropertyImpl pp = new JobPropertyImpl(p);
p.addProperty(pp);
@@ -51,7 +63,8 @@ public void testRoundtrip() throws Exception {
proc.icon = "star-blue";
// round trip
- submit(new WebClient().getPage(p,"configure").getFormByName("config"));
+ JenkinsRule.WebClient wc = j.createWebClient();
+ submit(wc.getPage(p,"configure").getFormByName("config"));
// assert that the configuration is still intact
pp = p.getProperty(JobPropertyImpl.class);
@@ -68,11 +81,12 @@ public void testRoundtrip() throws Exception {
}
@LocalData
- @Bug(17341)
+ @Issue("JENKINS-17341")
+ @Test
public void testLoad() throws Exception {
- FreeStyleProject j = jenkins.getItemByFullName("j", FreeStyleProject.class);
- assertNotNull(j);
- Promotion p = j.getProperty(JobPropertyImpl.class).getItem("OK").getBuildByNumber(1);
+ FreeStyleProject jProj = j.jenkins.getItemByFullName("j", FreeStyleProject.class);
+ assertNotNull(jProj);
+ Promotion p = jProj.getProperty(JobPropertyImpl.class).getItem("OK").getBuildByNumber(1);
assertNotNull(p);
}
diff --git a/src/test/java/hudson/plugins/promoted_builds/KeepBuildForeverActionTest.java b/src/test/java/hudson/plugins/promoted_builds/KeepBuildForeverActionTest.java
index 7c293ee6..84b7d93b 100644
--- a/src/test/java/hudson/plugins/promoted_builds/KeepBuildForeverActionTest.java
+++ b/src/test/java/hudson/plugins/promoted_builds/KeepBuildForeverActionTest.java
@@ -14,7 +14,9 @@
import hudson.tasks.ArtifactArchiver;
import hudson.tasks.Fingerprinter;
import hudson.tasks.Recorder;
-import org.jvnet.hudson.test.HudsonTestCase;
+import org.junit.Rule;
+import org.junit.Test;
+import org.jvnet.hudson.test.JenkinsRule;
import org.jvnet.hudson.test.TestBuilder;
import java.io.IOException;
@@ -22,9 +24,16 @@
import java.util.List;
import static hudson.plugins.promoted_builds.util.ItemListenerHelper.fireItemListeners;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
-public class KeepBuildForeverActionTest extends HudsonTestCase {
-
+public class KeepBuildForeverActionTest {
+
+ @Rule
+ public JenkinsRule j = new JenkinsRule();
+
+ @Test
public void testCanMarkBuildKeepForever() throws Exception {
FreeStyleProject upJob = createProject("up");
upJob.getBuildersList().add(successfulBuilder());
@@ -37,14 +46,15 @@ public void testCanMarkBuildKeepForever() throws Exception {
// fire ItemListeners, this includes ArtifactArchiver,Migrator to make this test compatible with jenkins 1.575+
fireItemListeners();
- FreeStyleBuild upBuild = assertBuildStatusSuccess(upJob.scheduleBuild2(0).get());
+ FreeStyleBuild upBuild = j.assertBuildStatusSuccess(upJob.scheduleBuild2(0).get());
assertFalse(upBuild.isKeepLog());
- assertBuildStatusSuccess(downJob.scheduleBuild2(0).get());
+ j.assertBuildStatusSuccess(downJob.scheduleBuild2(0).get());
waitForBuild(promotionJob, 1);
assertTrue(upBuild.isKeepLog());
}
-
+
+ @Test
public void testDoesNotMarkBuildIfPromotionNotGoodEnough() throws Exception {
FreeStyleProject upJob = createProject("up");
upJob.getBuildersList().add(successfulBuilder());
@@ -58,14 +68,15 @@ public void testDoesNotMarkBuildIfPromotionNotGoodEnough() throws Exception {
// fire ItemListeners, this includes ArtifactArchiver,Migrator to make this test compatible with jenkins 1.575+
fireItemListeners();
- FreeStyleBuild upBuild = assertBuildStatusSuccess(upJob.scheduleBuild2(0).get());
+ FreeStyleBuild upBuild = j.assertBuildStatusSuccess(upJob.scheduleBuild2(0).get());
assertFalse(upBuild.isKeepLog());
- assertBuildStatusSuccess(downJob.scheduleBuild2(0).get());
+ j.assertBuildStatusSuccess(downJob.scheduleBuild2(0).get());
waitForBuild(promotionJob, 1);
assertFalse(upBuild.isKeepLog());
}
+ @Test
public void testDoesNotCareAboutResultOfOriginalBuild() throws Exception {
FreeStyleProject upJob = createProject("up");
upJob.getBuildersList().add(new FixedResultBuilder(Result.FAILURE));
@@ -78,14 +89,15 @@ public void testDoesNotCareAboutResultOfOriginalBuild() throws Exception {
// fire ItemListeners, this includes ArtifactArchiver,Migrator to make this test compatible with jenkins 1.575+
fireItemListeners();
- FreeStyleBuild upBuild = assertBuildStatus(Result.FAILURE, upJob.scheduleBuild2(0).get());
+ FreeStyleBuild upBuild = j.assertBuildStatus(Result.FAILURE, upJob.scheduleBuild2(0).get());
assertFalse(upBuild.isKeepLog());
- assertBuildStatusSuccess(downJob.scheduleBuild2(0).get());
+ j.assertBuildStatusSuccess(downJob.scheduleBuild2(0).get());
waitForBuild(promotionJob, 1);
assertTrue(upBuild.isKeepLog());
}
+ @Test
public void testDoesNotMarkBuildIfBuildNotPromotion() throws Exception {
FreeStyleProject job = createProject("job");
job.getBuildersList().add(successfulBuilder());
@@ -94,7 +106,7 @@ public void testDoesNotMarkBuildIfBuildNotPromotion() throws Exception {
// fire ItemListeners, this includes ArtifactArchiver,Migrator to make this test compatible with jenkins 1.575+
fireItemListeners();
- FreeStyleBuild build = assertBuildStatus(Result.FAILURE, job.scheduleBuild2(0).get());
+ FreeStyleBuild build = j.assertBuildStatus(Result.FAILURE, job.scheduleBuild2(0).get());
assertFalse(build.isKeepLog());
}
@@ -135,16 +147,15 @@ private PromotionProcess createDownstreamSuccessPromotion(FreeStyleProject upStr
}
private FreeStyleProject createProject(String name) throws Exception {
- FreeStyleProject project = createFreeStyleProject(name);
+ FreeStyleProject project = j.createFreeStyleProject(name);
project.getPublishersList().replaceBy(createFingerprinters());
return project;
}
private List createFingerprinters() {
- return Arrays.asList(
- new ArtifactArchiver("*", null, false),
- new Fingerprinter("", true)
- );
+ Recorder r1 = new ArtifactArchiver("*", null, false);
+ Recorder r2 = new Fingerprinter("", true);
+ return Arrays.asList(r1, r2);
}
private FixedResultBuilder successfulBuilder() {
diff --git a/src/test/java/hudson/plugins/promoted_builds/PromotedBuildActionTest.java b/src/test/java/hudson/plugins/promoted_builds/PromotedBuildActionTest.java
index 0f39a6c1..adb19d51 100644
--- a/src/test/java/hudson/plugins/promoted_builds/PromotedBuildActionTest.java
+++ b/src/test/java/hudson/plugins/promoted_builds/PromotedBuildActionTest.java
@@ -6,23 +6,32 @@
import hudson.model.FreeStyleBuild;
import hudson.model.FreeStyleProject;
import hudson.util.IOException2;
-import org.jvnet.hudson.test.HudsonTestCase;
+import org.junit.Rule;
+import org.junit.Test;
+import org.jvnet.hudson.test.JenkinsRule;
import java.io.IOException;
import java.util.List;
+import static org.junit.Assert.assertTrue;
+
/**
* @author Kohsuke Kawaguchi
*/
-public class PromotedBuildActionTest extends HudsonTestCase {
+public class PromotedBuildActionTest {
+
+ @Rule
+ public JenkinsRule j = new JenkinsRule();
+
+ @Test
public void testDeletedPromotionProcess() throws Exception {
- FreeStyleProject p = createFreeStyleProject();
+ FreeStyleProject p = j.createFreeStyleProject();
JobPropertyImpl base = new JobPropertyImpl(p);
p.addProperty(base);
PromotionProcess foo = base.addProcess("foo");
// promote a build
- FreeStyleBuild b1 = assertBuildStatusSuccess(p.scheduleBuild2(0));
+ FreeStyleBuild b1 = j.assertBuildStatusSuccess(p.scheduleBuild2(0));
foo.promote(b1,new UserCause(),new ManualPromotionBadge());
// now delete the promotion process
@@ -31,7 +40,7 @@ public void testDeletedPromotionProcess() throws Exception {
assertTrue(base.getActiveItems().isEmpty());
// make sure that the page renders OK without any error
- HtmlPage page = createWebClient().getPage(p);
+ HtmlPage page = j.createWebClient().getPage(p);
List> candidates = page.getByXPath("//IMG");
for (Object candidate : candidates) {
if (!(candidate instanceof HtmlImage)) {
diff --git a/src/test/java/hudson/plugins/promoted_builds/PromotionProcessTest.java b/src/test/java/hudson/plugins/promoted_builds/PromotionProcessTest.java
index a3e620d6..956284bb 100644
--- a/src/test/java/hudson/plugins/promoted_builds/PromotionProcessTest.java
+++ b/src/test/java/hudson/plugins/promoted_builds/PromotionProcessTest.java
@@ -15,7 +15,9 @@
import hudson.tasks.Shell;
import hudson.plugins.promoted_builds.conditions.DownstreamPassCondition;
import net.sf.json.JSONObject;
-import org.jvnet.hudson.test.HudsonTestCase;
+import org.junit.Rule;
+import org.junit.Test;
+import org.jvnet.hudson.test.JenkinsRule;
import org.kohsuke.stapler.Stapler;
import java.util.ArrayList;
@@ -24,18 +26,24 @@
import java.util.concurrent.Callable;
import static hudson.plugins.promoted_builds.util.ItemListenerHelper.fireItemListeners;
+import static org.junit.Assert.*;
/**
* @author Kohsuke Kawaguchi
*/
-public class PromotionProcessTest extends HudsonTestCase {
+public class PromotionProcessTest {
+
+ @Rule
+ public JenkinsRule j = new JenkinsRule();
+
+ @Test
public void test1() throws Exception {
- FreeStyleProject up = createFreeStyleProject("up");
- FreeStyleProject down = createFreeStyleProject();
+ FreeStyleProject up = j.createFreeStyleProject("up");
+ FreeStyleProject down = j.createFreeStyleProject();
- List recorders = Arrays.asList(
- new ArtifactArchiver("a.jar", null, false),
- new Fingerprinter("", true));
+ Recorder r1 = new ArtifactArchiver("a.jar", null, false);
+ Recorder r2 = new Fingerprinter("", true);
+ List recorders = Arrays.asList(r1, r2);
// upstream job
up.getBuildersList().add(new Shell("date > a.jar"));
@@ -48,7 +56,7 @@ public void test1() throws Exception {
proc.conditions.add(new DownstreamPassCondition(down.getName()));
// this is the test job
- String baseUrl = new WebClient().getContextPath() + "job/up/lastSuccessfulBuild";
+ String baseUrl = j.createWebClient().getContextPath() + "job/up/lastSuccessfulBuild";
down.getBuildersList().add(new Shell(
"wget -N "+baseUrl+"/artifact/a.jar \\\n"+
" || curl "+baseUrl+"/artifact/a.jar > a.jar\n"+
@@ -60,13 +68,13 @@ public void test1() throws Exception {
fireItemListeners();
// not yet promoted while the downstream is failing
- FreeStyleBuild up1 = assertBuildStatusSuccess(up.scheduleBuild2(0).get());
- assertBuildStatus(Result.FAILURE,down.scheduleBuild2(0).get());
+ FreeStyleBuild up1 = j.assertBuildStatusSuccess(up.scheduleBuild2(0).get());
+ j.assertBuildStatus(Result.FAILURE,down.scheduleBuild2(0).get());
Thread.sleep(1000); // give it a time to not promote
assertEquals(0,proc.getBuilds().size());
// a successful downstream build promotes upstream
- assertBuildStatusSuccess(down.scheduleBuild2(0).get());
+ j.assertBuildStatusSuccess(down.scheduleBuild2(0).get());
Thread.sleep(1000); // give it a time to promote
assertEquals(1,proc.getBuilds().size());
@@ -78,16 +86,16 @@ public void test1() throws Exception {
}
// make sure the UI persists the setup
- configRoundtrip(up);
-
+ j.configRoundtrip(up);
}
/**
* Tests a promotion induced by the pseudo upstream/downstream cause relationship
*/
+ @Test
public void testPromotionWithoutFingerprint() throws Exception {
- FreeStyleProject up = createFreeStyleProject("up");
- FreeStyleProject down = createFreeStyleProject();
+ FreeStyleProject up = j.createFreeStyleProject("up");
+ FreeStyleProject down = j.createFreeStyleProject();
// promote if the downstream passes
JobPropertyImpl promotion = new JobPropertyImpl(up);
@@ -97,7 +105,7 @@ public void testPromotionWithoutFingerprint() throws Exception {
// trigger downstream automatically to create relationship
up.getPublishersList().add(new BuildTrigger(down.getName(), Result.SUCCESS));
- hudson.rebuildDependencyGraph();
+ j.jenkins.rebuildDependencyGraph();
// this is the downstream job
down.getBuildersList().add(new Shell(
@@ -105,12 +113,12 @@ public void testPromotionWithoutFingerprint() throws Exception {
));
// not yet promoted while the downstream is failing
- FreeStyleBuild up1 = assertBuildStatusSuccess(up.scheduleBuild2(0).get());
+ FreeStyleBuild up1 = j.assertBuildStatusSuccess(up.scheduleBuild2(0).get());
waitForCompletion(down,1);
assertEquals(0,proc.getBuilds().size());
// do it one more time and this time it should work
- FreeStyleBuild up2 = assertBuildStatusSuccess(up.scheduleBuild2(0).get());
+ FreeStyleBuild up2 = j.assertBuildStatusSuccess(up.scheduleBuild2(0).get());
waitForCompletion(down,2);
assertEquals(1,proc.getBuilds().size());
@@ -126,12 +134,13 @@ private void waitForCompletion(FreeStyleProject down, int n) throws Exception {
// wait for the build completion
while (down.getBuildByNumber(n)==null)
Thread.sleep(100);
- waitUntilNoActivity();
+ j.waitUntilNoActivity();
assertFalse(down.getBuildByNumber(n).isBuilding());
}
+ @Test
public void testCaptureXml() throws Exception {
- executeOnServer(new Callable