Java Code Examples for hudson.util.OneShotEvent#block()
The following examples show how to use
hudson.util.OneShotEvent#block() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PushHookTriggerHandlerImplTest.java From gitlab-plugin with GNU General Public License v2.0 | 6 votes |
@Test public void push_ciSkip() throws IOException, InterruptedException { final OneShotEvent buildTriggered = new OneShotEvent(); FreeStyleProject project = jenkins.createFreeStyleProject(); project.getBuildersList().add(new TestBuilder() { @Override public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException { buildTriggered.signal(); return true; } }); project.setQuietPeriod(0); pushHookTriggerHandler.handle(project, pushHook() .withCommits(Arrays.asList(commit().withMessage("some message").build(), commit().withMessage("[ci-skip]").build())) .build(), true, newBranchFilter(branchFilterConfig().build(BranchFilterType.All)), newMergeRequestLabelFilter(null)); buildTriggered.block(10000); assertThat(buildTriggered.isSignaled(), is(false)); }
Example 2
Source File: MergeRequestHookTriggerHandlerImplTest.java From gitlab-plugin with GNU General Public License v2.0 | 6 votes |
private boolean ciSkipTestHelper(String MRDescription, String lastCommitMsg) throws IOException, InterruptedException { final OneShotEvent buildTriggered = new OneShotEvent(); FreeStyleProject project = jenkins.createFreeStyleProject(); project.getBuildersList().add(new TestBuilder() { @Override public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException { buildTriggered.signal(); return true; } }); project.setQuietPeriod(0); MergeRequestHookTriggerHandler mergeRequestHookTriggerHandler = new MergeRequestHookTriggerHandlerImpl(Arrays.asList(State.opened, State.reopened), Arrays.asList(Action.approved), false, false, false); mergeRequestHookTriggerHandler.handle(project, mergeRequestHook() .withObjectAttributes(defaultMergeRequestObjectAttributes().withDescription(MRDescription).withLastCommit(commit().withMessage(lastCommitMsg).withAuthor(user().withName("test").build()).withId("testid").build()).build()) .build(), true, BranchFilterFactory.newBranchFilter(branchFilterConfig().build(BranchFilterType.All)), newMergeRequestLabelFilter(null)); buildTriggered.block(10000); return buildTriggered.isSignaled(); }
Example 3
Source File: PipelineHookTriggerHandlerImplTest.java From gitlab-plugin with GNU General Public License v2.0 | 6 votes |
@Test public void pipeline_build() throws IOException, InterruptedException, GitAPIException, ExecutionException { final OneShotEvent buildTriggered = new OneShotEvent(); FreeStyleProject project = jenkins.createFreeStyleProject(); project.getBuildersList().add(new TestBuilder() { @Override public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException { buildTriggered.signal(); return true; } }); project.setQuietPeriod(0); pipelineHookTriggerHandler.handle(project, pipelineHook, false, newBranchFilter(branchFilterConfig().build(BranchFilterType.All)), newMergeRequestLabelFilter(null)); buildTriggered.block(10000); assertThat(buildTriggered.isSignaled(), is(true)); }
Example 4
Source File: PipelineHookTriggerHandlerImplTest.java From gitlab-plugin with GNU General Public License v2.0 | 6 votes |
@Test /** * always triggers since pipeline events do not contain ci skip message */ public void pipeline_ciSkip() throws IOException, InterruptedException { final OneShotEvent buildTriggered = new OneShotEvent(); FreeStyleProject project = jenkins.createFreeStyleProject(); project.getBuildersList().add(new TestBuilder() { @Override public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException { buildTriggered.signal(); return true; } }); project.setQuietPeriod(0); pipelineHookTriggerHandler.handle(project, pipelineHook , true, newBranchFilter(branchFilterConfig().build(BranchFilterType.All)), newMergeRequestLabelFilter(null)); buildTriggered.block(10000); assertThat(buildTriggered.isSignaled(), is(true)); }
Example 5
Source File: WorkSpaceZipperTest.java From aws-lambda-jenkins-plugin with MIT License | 5 votes |
@Test public void testGetZipWithZip() throws Exception { final OneShotEvent buildEnded = new OneShotEvent(); FreeStyleProject p = j.createFreeStyleProject(); p.getBuildersList().add(new TestBuilder() { public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException { build.getWorkspace().child("echo.zip").copyFrom(new FileInputStream(testUtil.getResource("echo.zip"))); buildEnded.signal(); return true; } }); p.scheduleBuild2(0); buildEnded.block(); JenkinsLogger logger = new JenkinsLogger(System.out); WorkSpaceZipper workSpaceZipper = new WorkSpaceZipper(p.getSomeWorkspace(), logger); File zip = workSpaceZipper.getZip("echo.zip"); assertTrue(zip.exists()); assertTrue(zip.getAbsolutePath().contains("awslambda-")); ZipFile zipFile = new ZipFile(zip); assertNotNull(zipFile); assertNotNull(zipFile.getEntry("index.js")); }
Example 6
Source File: WorkSpaceZipperTest.java From aws-lambda-jenkins-plugin with MIT License | 5 votes |
@Test public void testGetZipFolder() throws Exception { final OneShotEvent buildEnded = new OneShotEvent(); FreeStyleProject p = j.createFreeStyleProject(); p.getBuildersList().add(new TestBuilder() { public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException { build.getWorkspace().child("echo").child("index.js").copyFrom(new FileInputStream(testUtil.getResource("echo/index.js"))); buildEnded.signal(); return true; } }); p.scheduleBuild2(0); buildEnded.block(); JenkinsLogger logger = new JenkinsLogger(System.out); WorkSpaceZipper workSpaceZipper = new WorkSpaceZipper(p.getSomeWorkspace(), logger); File zip = workSpaceZipper.getZip("echo"); assertTrue(zip.exists()); assertTrue(zip.getAbsolutePath().contains("awslambda-")); ZipFile zipFile = new ZipFile(zip); assertNotNull(zipFile); assertNotNull(zipFile.getEntry("index.js")); }
Example 7
Source File: WorkSpaceZipperTest.java From aws-lambda-jenkins-plugin with MIT License | 5 votes |
@Test public void testGetZipFolderEmpty() throws Exception { final OneShotEvent buildEnded = new OneShotEvent(); FreeStyleProject p = j.createFreeStyleProject(); p.getBuildersList().add(new TestBuilder() { public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException { build.getWorkspace().child("echo").mkdirs(); buildEnded.signal(); return true; } }); p.scheduleBuild2(0); buildEnded.block(); JenkinsLogger logger = new JenkinsLogger(System.out); WorkSpaceZipper workSpaceZipper = new WorkSpaceZipper(p.getSomeWorkspace(), logger); File zip = workSpaceZipper.getZip("echo"); assertTrue(zip.exists()); assertTrue(zip.getAbsolutePath().contains("awslambda-")); ZipFile zipFile = new ZipFile(zip); assertNotNull(zipFile); assertFalse(zipFile.entries().hasMoreElements()); }
Example 8
Source File: AbstractJenkinsTestProject.java From aws-codecommit-trigger-plugin with Apache License 2.0 | 5 votes |
protected void submitAndAssertFixture(ProjectFixture fixture) throws Exception { this.subscribeProject(fixture); OneShotEvent event = fixture.getEvent(); event.block(fixture.getTimeout()); Assertions.assertThat(event.isSignaled()) .describedAs("Fixture %s should be pass", fixture.getName()) .isEqualTo(fixture.getShouldStarted()); }
Example 9
Source File: NoteHookTriggerHandlerImplTest.java From gitlab-plugin with GNU General Public License v2.0 | 5 votes |
@Test public void note_ciSkip() throws IOException, InterruptedException { final OneShotEvent buildTriggered = new OneShotEvent(); FreeStyleProject project = jenkins.createFreeStyleProject(); project.getBuildersList().add(new TestBuilder() { @Override public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException { buildTriggered.signal(); return true; } }); Date currentDate = new Date(); project.setQuietPeriod(0); noteHookTriggerHandler.handle(project, noteHook() .withObjectAttributes(noteObjectAttributes() .withId(1) .withNote("ci-run") .withAuthorId(1) .withProjectId(1) .withCreatedAt(currentDate) .withUpdatedAt(currentDate) .withUrl("https://gitlab.org/test/merge_requests/1#note_1") .build()) .withMergeRequest(mergeRequestObjectAttributes().withDescription("[ci-skip]").build()) .build(), true, BranchFilterFactory.newBranchFilter(branchFilterConfig().build(BranchFilterType.All)), newMergeRequestLabelFilter(null)); buildTriggered.block(10000); assertThat(buildTriggered.isSignaled(), is(false)); }
Example 10
Source File: SseEventTest.java From blueocean-plugin with MIT License | 5 votes |
@Test public void jobRunEvents() throws IOException, ExecutionException, InterruptedException { final OneShotEvent success = new OneShotEvent(); final FreeStyleProject p = j.createFreeStyleProject("test1"); final AssertionHelper assertionHelper = new AssertionHelper(); SSEConnection con = new SSEConnection(j.getURL(), "me", new ChannelSubscriber() { @Override public void onMessage(@Nonnull Message message) { System.out.println(message); assertionHelper.isEquals("/blue/rest/organizations/jenkins/pipelines/test1/", message.get(blueocean_job_rest_url)); assertionHelper.isEquals(p.getName(), message.get(blueocean_job_pipeline_name)); if(message.get(jenkins_event).equals(Events.JobChannel.job_run_queue_left.name())) { assertionHelper.isEquals("1", message.get(blueocean_queue_item_expected_build_number)); } assertionHelper.isEquals(p.getName(), message.get(job_name)); assertionHelper.isEquals("job", message.get(jenkins_channel)); assertionHelper.isEquals("jenkins", message.get(jenkins_org)); assertionHelper.isNull(message.get(job_ismultibranch)); assertionHelper.isNull(message.get(job_multibranch_indexing_result)); assertionHelper.isNull(message.get(job_multibranch_indexing_status)); assertionHelper.isNotNull(message.get(Job.job_run_queueId)); assertionHelper.isNotNull(message.get(Job.job_run_status)); if ("SUCCESS".equals(message.get(Job.job_run_status)) && "job_run_ended".equals(message.get(jenkins_event))) success.signal(); } }); con.subscribe("job"); p.scheduleBuild2(0).get(); // make sure we got the event we were looking for success.block(5000); con.close(); if(assertionHelper.totalErrors() > 0){ fail("There were errors: "+ assertionHelper.totalErrors()); } }
Example 11
Source File: MergeRequestHookTriggerHandlerImplTest.java From gitlab-plugin with GNU General Public License v2.0 | 5 votes |
private OneShotEvent doHandle(MergeRequestHookTriggerHandler mergeRequestHookTriggerHandler, MergeRequestObjectAttributesBuilder objectAttributes) throws GitAPIException, IOException, InterruptedException { Git.init().setDirectory(tmp.getRoot()).call(); tmp.newFile("test"); Git git = Git.open(tmp.getRoot()); git.add().addFilepattern("test"); RevCommit commit = git.commit().setMessage("test").call(); ObjectId head = git.getRepository().resolve(Constants.HEAD); String repositoryUrl = tmp.getRoot().toURI().toString(); final OneShotEvent buildTriggered = new OneShotEvent(); FreeStyleProject project = jenkins.createFreeStyleProject(); project.setScm(new GitSCM(repositoryUrl)); project.getBuildersList().add(new TestBuilder() { @Override public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException { buildTriggered.signal(); return true; } }); project.setQuietPeriod(0); mergeRequestHookTriggerHandler.handle(project, mergeRequestHook() .withObjectAttributes(objectAttributes .withTargetBranch("refs/heads/" + git.nameRev().add(head).call().get(head)) .withLastCommit(commit().withAuthor(user().withName("test").build()).withId(commit.getName()).build()) .build()) .withProject(project() .withWebUrl("https://gitlab.org/test.git") .build() ) .build(), true, BranchFilterFactory.newBranchFilter(branchFilterConfig().build(BranchFilterType.All)), newMergeRequestLabelFilter(null)); buildTriggered.block(10000); return buildTriggered; }
Example 12
Source File: SseEventTest.java From blueocean-plugin with MIT License | 5 votes |
@Test public void jobCreationEvents() throws IOException, ExecutionException, InterruptedException { final OneShotEvent success = new OneShotEvent(); final AssertionHelper assertionHelper = new AssertionHelper(); SSEConnection con = new SSEConnection(j.getURL(), "me", new ChannelSubscriber() { @Override public void onMessage(@Nonnull Message message) { System.out.println(message); assertionHelper.isEquals("job_crud_created", message.get(jenkins_event)); assertionHelper.isEquals("/blue/rest/organizations/jenkins/pipelines/test1/", message.get(blueocean_job_rest_url)); assertionHelper.isEquals("test1", message.get(blueocean_job_pipeline_name)); assertionHelper.isEquals("test1", message.get(job_name)); assertionHelper.isEquals("job", message.get(jenkins_channel)); assertionHelper.isNull(message.get(job_ismultibranch)); assertionHelper.isNull(message.get(job_multibranch_indexing_result)); assertionHelper.isNull(message.get(job_multibranch_indexing_status)); assertionHelper.isNull(message.get(Job.job_run_queueId)); assertionHelper.isNull(message.get(Job.job_run_status)); if ("job_crud_created".equals(message.get(jenkins_event))) success.signal(); } }); con.subscribe("job"); j.createFreeStyleProject("test1"); // make sure we got the event we were looking for success.block(5000); con.close(); if(assertionHelper.totalErrors() > 0){ fail("There were errors: "+ assertionHelper.totalErrors()); } }
Example 13
Source File: SseEventTest.java From blueocean-plugin with MIT License | 4 votes |
@Test public void multiBranchJobEventsWithCustomOrg() throws Exception { MockFolder folder = j.createFolder("TestOrgFolderName"); assertNotNull(folder); setupScm(); final OneShotEvent success = new OneShotEvent(); final Boolean[] pipelineNameMatched = {null}; final Boolean[] mbpPipelineNameMatched = {null}; SSEConnection con = new SSEConnection(j.getURL(), "me", new ChannelSubscriber() { @Override public void onMessage(@Nonnull Message message) { System.out.println(message); if("job".equals(message.get(jenkins_channel))) { if ("org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject".equals(message.get(jenkins_object_type))) { if("pipeline1".equals(message.get(blueocean_job_pipeline_name))) { mbpPipelineNameMatched[0] = true; }else{ mbpPipelineNameMatched[0] = false; } } else if ("org.jenkinsci.plugins.workflow.job.WorkflowJob".equals(message.get(jenkins_object_type))) { if("pipeline1".equals(message.get(blueocean_job_pipeline_name))) { pipelineNameMatched[0] = true; }else { pipelineNameMatched[0] = false; } } } if(pipelineNameMatched[0] != null && mbpPipelineNameMatched[0] != null){ success.signal(); } } }); con.subscribe("pipeline"); con.subscribe("job"); final WorkflowMultiBranchProject mp = folder.createProject(WorkflowMultiBranchProject.class, "pipeline1"); mp.getSourcesList().add(new BranchSource(new GitSCMSource(null, sampleRepo.toString(), "", "*", "", false), new DefaultBranchPropertyStrategy(new BranchProperty[0]))); for (SCMSource source : mp.getSCMSources()) { assertEquals(mp, source.getOwner()); } mp.scheduleBuild2(0).getFuture().get(); WorkflowJob p = mp.getItem("master"); if (p == null) { mp.getIndexing().writeWholeLogTo(System.out); fail("master project not found"); } j.waitUntilNoActivity(); WorkflowRun b1 = p.getLastBuild(); assertEquals(1, b1.getNumber()); assertEquals(2, mp.getItems().size()); success.block(5000); con.close(); if(success.isSignaled()) { assertTrue(pipelineNameMatched[0]); assertTrue(mbpPipelineNameMatched[0]); } }
Example 14
Source File: PushHookTriggerHandlerImplTest.java From gitlab-plugin with GNU General Public License v2.0 | 4 votes |
@Test public void push_build() throws IOException, InterruptedException, GitAPIException, ExecutionException { Git.init().setDirectory(tmp.getRoot()).call(); tmp.newFile("test"); Git git = Git.open(tmp.getRoot()); git.add().addFilepattern("test"); RevCommit commit = git.commit().setMessage("test").call(); ObjectId head = git.getRepository().resolve(Constants.HEAD); String repositoryUrl = tmp.getRoot().toURI().toString(); final OneShotEvent buildTriggered = new OneShotEvent(); FreeStyleProject project = jenkins.createFreeStyleProject(); project.setScm(new GitSCM(repositoryUrl)); project.getBuildersList().add(new TestBuilder() { @Override public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException { buildTriggered.signal(); return true; } }); project.setQuietPeriod(0); pushHookTriggerHandler.handle(project, pushHook() .withBefore("0000000000000000000000000000000000000000") .withProjectId(1) .withUserName("test") .withObjectKind("tag_push") .withRepository(repository() .withName("test") .withHomepage("https://gitlab.org/test") .withUrl("[email protected]:test.git") .withGitSshUrl("[email protected]:test.git") .withGitHttpUrl("https://gitlab.org/test.git") .build()) .withProject(project() .withNamespace("test-namespace") .withWebUrl("https://gitlab.org/test") .build()) .withAfter(commit.name()) .withRef("refs/heads/" + git.nameRev().add(head).call().get(head)) .build(), true, newBranchFilter(branchFilterConfig().build(BranchFilterType.All)), newMergeRequestLabelFilter(null)); buildTriggered.block(10000); assertThat(buildTriggered.isSignaled(), is(true)); }
Example 15
Source File: PushHookTriggerHandlerImplTest.java From gitlab-plugin with GNU General Public License v2.0 | 4 votes |
@Test public void push_build2DifferentBranchesButSameCommit() throws IOException, InterruptedException, GitAPIException, ExecutionException { Git.init().setDirectory(tmp.getRoot()).call(); tmp.newFile("test"); Git git = Git.open(tmp.getRoot()); git.add().addFilepattern("test"); RevCommit commit = git.commit().setMessage("test").call(); ObjectId head = git.getRepository().resolve(Constants.HEAD); String repositoryUrl = tmp.getRoot().toURI().toString(); final AtomicInteger buildCount = new AtomicInteger(0); final OneShotEvent buildTriggered = new OneShotEvent(); FreeStyleProject project = jenkins.createFreeStyleProject(); project.setScm(new GitSCM(repositoryUrl)); project.getBuildersList().add(new TestBuilder() { @Override public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException { int count = buildCount.incrementAndGet(); if (count == 2) { buildTriggered.signal(); } return true; } }); project.setQuietPeriod(0); PushHookBuilder pushHookBuilder = pushHook() .withBefore("0000000000000000000000000000000000000000") .withProjectId(1) .withUserName("test") .withObjectKind("push") .withRepository(repository() .withName("test") .withHomepage("https://gitlab.org/test") .withUrl("[email protected]:test.git") .withGitSshUrl("[email protected]:test.git") .withGitHttpUrl("https://gitlab.org/test.git") .build()) .withProject(project() .withNamespace("test-namespace") .withWebUrl("https://gitlab.org/test") .build()) .withAfter(commit.name()) .withRef("refs/heads/" + git.nameRev().add(head).call().get(head)); pushHookTriggerHandler.handle(project, pushHookBuilder.build(), true, newBranchFilter(branchFilterConfig().build(BranchFilterType.All)), newMergeRequestLabelFilter(null)); pushHookTriggerHandler.handle(project, pushHookBuilder .but().withRef("refs/heads/" + git.nameRev().add(head).call().get(head) + "-2").build(), true, newBranchFilter(branchFilterConfig().build(BranchFilterType.All)), newMergeRequestLabelFilter(null)); buildTriggered.block(10000); assertThat(buildTriggered.isSignaled(), is(true)); assertThat(buildCount.intValue(), is(2)); }
Example 16
Source File: NoteHookTriggerHandlerImplTest.java From gitlab-plugin with GNU General Public License v2.0 | 4 votes |
@Test public void note_build() throws IOException, InterruptedException, GitAPIException, ExecutionException { Git.init().setDirectory(tmp.getRoot()).call(); tmp.newFile("test"); Git git = Git.open(tmp.getRoot()); git.add().addFilepattern("test"); RevCommit commit = git.commit().setMessage("test").call(); ObjectId head = git.getRepository().resolve(Constants.HEAD); String repositoryUrl = tmp.getRoot().toURI().toString(); final OneShotEvent buildTriggered = new OneShotEvent(); FreeStyleProject project = jenkins.createFreeStyleProject(); project.setScm(new GitSCM(repositoryUrl)); project.getBuildersList().add(new TestBuilder() { @Override public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException { buildTriggered.signal(); return true; } }); Date currentDate = new Date(); project.setQuietPeriod(0); noteHookTriggerHandler.handle(project, noteHook() .withObjectAttributes(noteObjectAttributes() .withId(1) .withNote("ci-run") .withAuthorId(1) .withProjectId(1) .withCreatedAt(currentDate) .withUpdatedAt(currentDate) .withUrl("https://gitlab.org/test/merge_requests/1#note_1") .build()) .withMergeRequest(mergeRequestObjectAttributes() .withTargetBranch("refs/heads/" + git.nameRev().add(head).call().get(head)) .withState(State.opened) .withIid(1) .withTitle("test") .withTargetProjectId(1) .withSourceProjectId(1) .withSourceBranch("feature") .withTargetBranch("master") .withLastCommit(commit().withAuthor(user().withName("test").build()).withId(commit.getName()).build()) .withSource(project() .withName("test") .withNamespace("test-namespace") .withHomepage("https://gitlab.org/test") .withUrl("[email protected]:test.git") .withSshUrl("[email protected]:test.git") .withHttpUrl("https://gitlab.org/test.git") .build()) .withTarget(project() .withName("test") .withNamespace("test-namespace") .withHomepage("https://gitlab.org/test") .withUrl("[email protected]:test.git") .withSshUrl("[email protected]:test.git") .withHttpUrl("https://gitlab.org/test.git") .withWebUrl("https://gitlab.org/test.git") .build()) .build()) .build(), true, BranchFilterFactory.newBranchFilter(branchFilterConfig().build(BranchFilterType.All)), newMergeRequestLabelFilter(null)); buildTriggered.block(10000); assertThat(buildTriggered.isSignaled(), is(true)); }
Example 17
Source File: SseEventTest.java From blueocean-plugin with MIT License | 4 votes |
@Test public void pipelineWithInput() throws IOException, ExecutionException, InterruptedException, TimeoutException { final OneShotEvent success = new OneShotEvent(); String script = "node {\n" + " stage(\"build\"){\n" + " echo \"running\"\n" + " input message: 'Please input branch to test against', parameters: [[$class: 'StringParameterDefinition', defaultValue: 'master', description: '', name: 'branch']]\n" + " }\n" + "}"; final boolean[] wasPaused = {false}; final boolean[] wasUnPaused = {false}; final AssertionHelper assertionHelper = new AssertionHelper(); SSEConnection con = new SSEConnection(j.getURL(), "me", new ChannelSubscriber() { @Override public void onMessage(@Nonnull Message message) { System.out.println(message); if("job".equals(message.get(jenkins_channel))) { assertionHelper.isEquals("/blue/rest/organizations/jenkins/pipelines/pipeline1/", message.get(blueocean_job_rest_url)); assertionHelper.isEquals("pipeline1", message.get(blueocean_job_pipeline_name)); if(message.get(jenkins_event).equals(Events.JobChannel.job_run_queue_left.name())) { assertionHelper.isEquals("1", message.get(blueocean_queue_item_expected_build_number)); assertionHelper.isNotNull(message.get(Job.job_run_queueId)); assertionHelper.isNotNull(message.get(Job.job_run_status)); } assertionHelper.isEquals("pipeline1", message.get(job_name)); assertionHelper.isEquals("job", message.get(jenkins_channel)); assertionHelper.isEquals("jenkins", message.get(jenkins_org)); assertionHelper.isNull(message.get(job_ismultibranch)); assertionHelper.isNull(message.get(job_multibranch_indexing_result)); assertionHelper.isNull(message.get(job_multibranch_indexing_status)); if("job_run_unpaused".equals(message.get(jenkins_event))){ wasUnPaused[0] = true; } }else if("pipeline".equals(message.get(jenkins_channel))){ assertionHelper.isEquals("1", message.get(pipeline_run_id)); if(message.get(jenkins_event).equals(pipeline_stage.name())) { assertionHelper.isEquals("build", message.get(pipeline_step_stage_name)); } if("input".equals(message.get(pipeline_step_name))){ wasPaused[0] = true; assertionHelper.isEquals("true", message.get(pipeline_step_is_paused)); } } if(wasPaused[0] && wasUnPaused[0]){ // signal finish only when both conditions are met success.signal(); } } }); con.subscribe("pipeline"); con.subscribe("job"); WorkflowJob job1 = j.jenkins.createProject(WorkflowJob.class, "pipeline1"); job1.setDefinition(new CpsFlowDefinition(script, false)); QueueTaskFuture<WorkflowRun> buildTask = job1.scheduleBuild2(0); WorkflowRun run = buildTask.getStartCondition().get(); CpsFlowExecution e = (CpsFlowExecution) run.getExecutionPromise().get(); while (run.getAction(InputAction.class) == null) { e.waitForSuspension(); } //Now that flow is paused, send a signal that it's un-paused ExtensionList<PipelineEventListener.InputStepPublisher> inputStepPublisherList = ExtensionList.lookup(PipelineEventListener.InputStepPublisher.class); assertFalse(inputStepPublisherList.isEmpty()); InputAction inputAction = run.getAction(InputAction.class); List<InputStepExecution> executionList = inputAction.getExecutions(); assertFalse(executionList.isEmpty()); InputStep inputStep = executionList.get(0).getInput(); inputStepPublisherList.get(0).onStepContinue(inputStep,run); success.block(5000); con.close(); if(success.isSignaled()){ assertTrue(wasPaused[0]); assertTrue(wasUnPaused[0]); } if(assertionHelper.totalErrors() > 0){ fail("There were errors: "+ assertionHelper.totalErrors()); } }