@Issue("JENKINS-37538") @Test public void contextClassLoader() throws Exception { WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p"); p.setDefinition(new CpsFlowDefinition("try {def c = classLoad(getClass().name); error(/did not expect to be able to load ${c} from ${c.classLoader}/)} catch (ClassNotFoundException x) {echo(/good, got ${x}/)}", false)); r.assertBuildStatusSuccess(p.scheduleBuild2(0)); }
@Test public void allRunsBuildSameRevisionOnUpdate() throws Exception { //schedule an initial build, to test update behavior later in the test j.assertBuildStatusSuccess(matrixProject.scheduleBuild2(0)); m.touchAndCommit(repo, "ab"); assertAllMatrixRunsBuildSameMercurialRevision(); }
private int checkoutWithFormat(int format) throws Exception { super.configureSvnWorkspaceFormat(format); FreeStyleProject project = r.jenkins.createProject(FreeStyleProject.class, "svntest" + format); SubversionSCM subversionSCM = new SubversionSCM("https://svn.jenkins-ci.org/trunk/hudson/test-projects/trivial-ant"); project.setScm(subversionSCM); r.assertBuildStatusSuccess(project.scheduleBuild2(0)); // Create a status client and get the working copy format. SVNClientManager testWCVerseion = SVNClientManager.newInstance(null, "testWCVerseion", null); File path = new File(project.getWorkspace().getRemote()); return testWCVerseion.getStatusClient().doStatus(path, true).getWorkingCopyFormat(); } }
@Issue("JENKINS-45455") @Test public void parametersAndRestart() throws Exception { // Initial build passes - we mainly just want it to add the parameters. WorkflowRun original = expect("restart", "parametersAndRestart").go(); WorkflowJob p = original.getParent(); WorkflowRun failing = p.scheduleBuild2(0, new ParametersAction(new BooleanParameterValue("flag", false), new StringParameterValue("someParam", "changed"))).waitForStart(); j.assertBuildStatus(Result.FAILURE, j.waitForCompletion(failing)); HtmlPage redirect = restartFromStageInUI(failing, "restart"); assertNotNull(redirect); assertEquals(p.getAbsoluteUrl(), redirect.getUrl().toString()); j.waitUntilNoActivity(); WorkflowRun b3 = p.getBuildByNumber(3); assertNotNull(b3); j.assertBuildStatusSuccess(b3); j.assertLogContains("Odd numbered build, success", b3); j.assertLogContains("Stage \"pre-restart\" skipped due to this build restarting at stage \"restart\"", b3); j.assertLogContains("Flag is false", b3); j.assertLogContains("someParam is changed", b3); j.assertLogContains("otherParam is should not change", b3); j.assertLogNotContains("hello on non-restart", b3); }
/** * Tests untyped arguments */ @Test public void userDefinedClosureUntypedArgInvocationExecution() throws Exception { WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p"); p.setDefinition(new CpsFlowDefinition("my_closure = { a , b -> \n" + " echo \"my message is ${a} and ${b}\" \n" + "}\n" + "my_closure(\"string1\" ,2)",false)); WorkflowRun b = r.assertBuildStatusSuccess(p.scheduleBuild2(0)); r.assertLogContains("my message is string1 and 2", b); }
@Issue("JENKINS-47780") @Test public void actualTriggerCorrectScope() throws Exception { WorkflowRun b = getAndStartNonRepoBuild("simpleTriggers"); j.assertBuildStatusSuccess(j.waitForCompletion(b)); expect("actualTriggerCorrectScope") .go(); } }
@Test @Issue("JENKINS-25630") public void contextInjectionOfSubParameters() throws Exception { // see SubtypeInjectingStep WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p"); p.setDefinition(new CpsFlowDefinition("node('master') { injectSubtypesAsContext() }", false)); r.assertBuildStatusSuccess(p.scheduleBuild2(0)); }
@Bug(18237) @Test public void multiSCMRunsBuildSameRevisionOnUpdate() throws Exception { setUpMultiSCM(); //schedule an initial build, to test update behavior later in the test j.assertBuildStatusSuccess(matrixProject.scheduleBuild2(0)); m.touchAndCommit(repo, "ab"); assertAllMatrixRunsBuildSameMercurialRevision(); }
/** * Tests the ability to execute a user defined closure with no arguments */ @Test public void userDefinedClosure0ArgsExecution() throws Exception { WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p"); p.setDefinition(new CpsFlowDefinition("binding.setVariable(\"my_closure\", { echo \"my closure!\" })\n my_closure() ", false)); WorkflowRun b = r.assertBuildStatusSuccess(p.scheduleBuild2(0)); r.assertLogContains("my closure!", b); }
/** * This is more of a test of the core, but make sure the triggers resolve between ourselves. */ @Test public void trigger() throws Exception { Folder f = createFolder(); FreeStyleProject a = f.createProject(FreeStyleProject.class, "a"); FreeStyleProject b = f.createProject(FreeStyleProject.class, "b"); a.getPublishersList().add(new BuildTrigger("b",false)); FreeStyleBuild a1 = r.assertBuildStatusSuccess(a.scheduleBuild2(0)); for (int i=0; i<10 && b.getLastBuild()==null; i++) { Thread.sleep(100); } // make sue that a build of B happens }
/** * Tests the ability to execute a user defined closure with one arguments */ @Test public void userDefinedClosure1ArgInvocationExecution() throws Exception { WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p"); p.setDefinition(new CpsFlowDefinition("my_closure = { String message -> \n" + " echo message \n" + "}\n" + "my_closure(\"my message!\") ", false)); WorkflowRun b = r.assertBuildStatusSuccess(p.scheduleBuild2(0)); r.assertLogContains("my message!", b); }
@Issue("JENKINS-16533") @Test public void pollingRespectExternalsWithRevision() throws Exception { // trunk has svn:externals="-r 1 ^/vendor vendor" (pinned) // latest commit on vendor is r3 (> r1) File repo = new CopyExisting(getClass().getResource("JENKINS-16533.zip")).allocate(); SubversionSCM scm = new SubversionSCM("file://" + repo.toURI().toURL().getPath() + "trunk"); // pinned externals should be recorded with ::p in revisions.txt FreeStyleProject p = r.createFreeStyleProject(); p.setScm(scm); p.setAssignedLabel(r.createSlave().getSelfLabel()); r.assertBuildStatusSuccess(p.scheduleBuild2(0).get()); // should not find any change (pinned externals should be skipped on poll) // fail if it checks the revision of external URL larger than the pinned revision assertFalse(p.poll(StreamTaskListener.fromStdout()).hasChanges()); }
/** * Tests the ability to execute a user defined closure with 2 arguments */ @Test public void userDefinedClosure2ArgInvocationExecution() throws Exception { WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p"); p.setDefinition(new CpsFlowDefinition("my_closure = { String message1, String message2 -> \n" + " echo \"my message is ${message1} and ${message2}\" \n" + "}\n" + "my_closure(\"string1\", \"string2\") ", false)); WorkflowRun b = r.assertBuildStatusSuccess(p.scheduleBuild2(0)); r.assertLogContains("my message is string1 and string2", b); }
@Url("http://hudson.pastebin.com/m3ea34eea") @Test @Ignore("TODO use docker-fixtures for a reproducible test case") public void remoteCheckOut() throws Exception { DumbSlave s = r.createSlave(); FreeStyleProject p = r.createFreeStyleProject(); p.setAssignedLabel(s.getSelfLabel()); p.setScm(new SubversionSCM("https://svn.jenkins-ci.org/trunk/hudson/test-projects/trivial-ant/")); FreeStyleBuild b = r.assertBuildStatusSuccess(p.scheduleBuild2(0, new Cause.UserIdCause()).get()); assertTrue(b.getWorkspace().child("build.xml").exists()); r.assertBuildStatusSuccess(p.scheduleBuild2(0).get()); }
@Test public void fullyQualifiedStep() throws Exception { WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p"); p.setDefinition(new CpsFlowDefinition("'org.jenkinsci.plugins.workflow.steps.EchoStep' 'Hello, world!'", true)); WorkflowRun b = r.assertBuildStatusSuccess(p.scheduleBuild2(0)); r.assertLogContains("Hello, world!", b); }
@Email("http://jenkins.361315.n4.nabble.com/Hudson-1-266-and-1-267-Subversion-authentication-broken-td375737.html") @Test @Ignore("TODO use docker-fixtures for a reproducible test case") public void httpsCheckOut() throws Exception { FreeStyleProject p = r.createFreeStyleProject(); p.setScm(new SubversionSCM("https://svn.jenkins-ci.org/trunk/hudson/test-projects/trivial-ant/")); FreeStyleBuild b = r.assertBuildStatusSuccess(p.scheduleBuild2(0, new Cause.UserIdCause()).get()); assertTrue(b.getWorkspace().child("build.xml").exists()); }
@Override public void evaluate() throws Throwable { p = jenkins().createProject(WorkflowJob.class, "demo"); p.setDefinition(new CpsFlowDefinition("parallel [:]", true)); story.j.assertBuildStatusSuccess(p.scheduleBuild2(0)); } });
@Email("http://jenkins.361315.n4.nabble.com/Hudson-1-266-and-1-267-Subversion-authentication-broken-td375737.html") @Test @Ignore("TODO use docker-fixtures for a reproducible test case") public void httpCheckOut() throws Exception { FreeStyleProject p = r.createFreeStyleProject(); p.setScm(new SubversionSCM("https://svn.jenkins-ci.org/trunk/hudson/test-projects/trivial-maven/src/test/java/test/")); FreeStyleBuild b = r.assertBuildStatusSuccess(p.scheduleBuild2(0, new Cause.UserIdCause()).get()); assertTrue(b.getWorkspace().child("AppTest.java").exists()); }
/** * Tests the ability to execute a user defined closure */ @Test public void userDefinedClosureInvocationExecution() throws Exception { WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p"); p.setDefinition(new CpsFlowDefinition("binding[\"my_closure\"] = { \n" + " sleep 1 \n" + " echo \"my closure!\" \n" + "}\n" + "my_closure() ", false)); WorkflowRun b = r.assertBuildStatusSuccess(p.scheduleBuild2(0)); r.assertLogContains("my closure!", b); }
@Issue("JENKINS-45455") @Test public void stashAndRestart() throws Exception { WorkflowRun original = expect(Result.FAILURE, "restart", "stashAndRestart").go(); WorkflowJob p = original.getParent(); HtmlPage redirect = restartFromStageInUI(original, "restart"); assertNotNull(redirect); assertEquals(p.getAbsoluteUrl(), redirect.getUrl().toString()); j.waitUntilNoActivity(); WorkflowRun b2 = p.getBuildByNumber(2); assertNotNull(b2); j.assertBuildStatusSuccess(b2); j.assertLogContains("Even numbered build, success", b2); j.assertLogContains("Stage \"pre-restart\" skipped due to this build restarting at stage \"restart\"", b2); j.assertLogContains("someFile is some text", b2); }