hudson.model.FreeStyleProject Java Examples
The following examples show how to use
hudson.model.FreeStyleProject.
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: MiscIssuesRecorderITest.java From warnings-ng-plugin with MIT License | 6 votes |
/** * Runs the CheckStyle and PMD tools for two corresponding files which contain 10 issues in total. Since a filter * afterwords removes all issues, the actual result contains no warnings. However, the two origins are still * reported with a total of 0 warnings per origin. */ @Test public void shouldHaveOriginsIfBuildContainsWarnings() { FreeStyleProject project = createFreeStyleProjectWithWorkspaceFiles("checkstyle.xml", "pmd-warnings.xml"); enableWarnings(project, recorder -> { recorder.setAggregatingResults(true); recorder.setFilters(Collections.singletonList(new ExcludeFile(".*"))); }, createTool(new CheckStyle(), "**/checkstyle-issues.txt"), createTool(new Pmd(), "**/pmd-warnings-issues.txt")); AnalysisResult result = getAnalysisResult(buildWithResult(project, Result.SUCCESS)); assertThat(result).hasTotalSize(0); assertThat(result.getSizePerOrigin()).containsExactly(entry("checkstyle", 0), entry("pmd", 0)); assertThat(result).hasId("analysis"); assertThat(result).hasQualityGateStatus(QualityGateStatus.INACTIVE); }
Example #2
Source File: LinkResolverTest.java From blueocean-plugin with MIT License | 6 votes |
@Test public void nestedFolderJobLinkResolveTest() throws IOException { Project f = j.createFreeStyleProject("fstyle1"); MockFolder folder1 = j.createFolder("folder1"); Project p1 = folder1.createProject(FreeStyleProject.class, "test1"); MockFolder folder2 = folder1.createProject(MockFolder.class, "folder2"); MockFolder folder3 = folder2.createProject(MockFolder.class, "folder3"); Project p2 = folder2.createProject(FreeStyleProject.class, "test2"); Project p3 = folder3.createProject(FreeStyleProject.class, "test3"); Assert.assertEquals("/blue/rest/organizations/jenkins/pipelines/fstyle1/",LinkResolver.resolveLink(f).getHref()); Assert.assertEquals("/blue/rest/organizations/jenkins/pipelines/folder1/",LinkResolver.resolveLink(folder1).getHref()); Assert.assertEquals("/blue/rest/organizations/jenkins/pipelines/folder1/pipelines/test1/",LinkResolver.resolveLink(p1).getHref()); Assert.assertEquals("/blue/rest/organizations/jenkins/pipelines/folder1/pipelines/folder2/",LinkResolver.resolveLink(folder2).getHref()); Assert.assertEquals("/blue/rest/organizations/jenkins/pipelines/folder1/pipelines/folder2/pipelines/test2/",LinkResolver.resolveLink(p2).getHref()); Assert.assertEquals("/blue/rest/organizations/jenkins/pipelines/folder1/pipelines/folder2/pipelines/folder3/",LinkResolver.resolveLink(folder3).getHref()); Assert.assertEquals("/blue/rest/organizations/jenkins/pipelines/folder1/pipelines/folder2/pipelines/folder3/pipelines/test3/",LinkResolver.resolveLink(p3).getHref()); }
Example #3
Source File: PipelineApiTest.java From blueocean-plugin with MIT License | 6 votes |
@Test public void PipelineSecureWithLoggedInUserPermissionTest() throws IOException, UnirestException { j.jenkins.setSecurityRealm(j.createDummySecurityRealm()); hudson.model.User user = User.get("alice"); user.setFullName("Alice Cooper"); MockFolder folder = j.createFolder("folder1"); Project p = folder.createProject(FreeStyleProject.class, "test1"); String token = getJwtToken(j.jenkins, "alice", "alice"); assertNotNull(token); Map response = new RequestBuilder(baseUrl) .get("/organizations/jenkins/pipelines/folder1/pipelines/test1") .jwtToken(token) .build(Map.class); validatePipeline(p, response); Map<String,Boolean> permissions = (Map<String, Boolean>) response.get("permissions"); assertTrue(permissions.get("create")); assertTrue(permissions.get("start")); assertTrue(permissions.get("stop")); assertTrue(permissions.get("read")); }
Example #4
Source File: FreeStyleProjectTest.java From lockable-resources-plugin with MIT License | 6 votes |
@Test public void configRoundTripWithScript() throws Exception { FreeStyleProject withScript = j.createFreeStyleProject("withScript"); SecureGroovyScript origScript = new SecureGroovyScript("return true", false, null); withScript.addProperty(new RequiredResourcesProperty(null, null, null, null, origScript)); FreeStyleProject withScriptRoundTrip = j.configRoundtrip(withScript); RequiredResourcesProperty withScriptProp = withScriptRoundTrip.getProperty(RequiredResourcesProperty.class); assertNotNull(withScriptProp); assertNull(withScriptProp.getResourceNames()); assertNull(withScriptProp.getResourceNamesVar()); assertNull(withScriptProp.getResourceNumber()); assertNull(withScriptProp.getLabelName()); assertNotNull(withScriptProp.getResourceMatchScript()); assertEquals("return true", withScriptProp.getResourceMatchScript().getScript()); assertFalse(withScriptProp.getResourceMatchScript().isSandbox()); }
Example #5
Source File: DockerContainerITest.java From warnings-ng-plugin with MIT License | 6 votes |
/** * Build a maven project on a docker container agent. * * @throws IOException * When the node assignment of the agent fails. * @throws InterruptedException * If the creation of the docker container fails. */ @Test public void shouldBuildMavenOnAgent() throws IOException, InterruptedException { assumeThat(isWindows()).as("Running on Windows").isFalse(); DumbSlave agent = createDockerContainerAgent(javaDockerRule.get()); FreeStyleProject project = createFreeStyleProject(); project.setAssignedNode(agent); createFileInAgentWorkspace(agent, project, "src/main/java/Test.java", getSampleJavaFile()); createFileInAgentWorkspace(agent, project, "pom.xml", getSampleMavenFile()); project.getBuildersList().add(new Maven("compile", null)); enableWarnings(project, createTool(new Java(), "")); scheduleSuccessfulBuild(project); FreeStyleBuild lastBuild = project.getLastBuild(); AnalysisResult result = getAnalysisResult(lastBuild); assertThat(result).hasTotalSize(2); assertThat(lastBuild.getBuiltOn().getLabelString()).isEqualTo(((Node) agent).getLabelString()); }
Example #6
Source File: DslJobRule.java From ansible-plugin with Apache License 2.0 | 6 votes |
private void before(Description description) throws Exception { FreeStyleProject job = jRule.createFreeStyleProject(); String script = description.getAnnotation(WithJobDsl.class).value(); String scriptText = Resources.toString(Resources.getResource(script), Charsets.UTF_8); job.getBuildersList().add( new ExecuteDslScripts( new ExecuteDslScripts.ScriptLocation( null, null, scriptText ), false, RemovedJobAction.DELETE, RemovedViewAction.DELETE, LookupStrategy.JENKINS_ROOT ) ); jRule.buildAndAssertSuccess(job); assertThat(jRule.getInstance().getJobNames(), hasItem(is(JOB_NAME_IN_DSL_SCRIPT))); generated = jRule.getInstance().getItemByFullName(JOB_NAME_IN_DSL_SCRIPT, FreeStyleProject.class); }
Example #7
Source File: MetricsAggregationPluginITest.java From warnings-ng-plugin with MIT License | 6 votes |
/** Verifies that the metrics action is available automatically. */ @Test public void shouldAggregateMetrics() { FreeStyleProject project = createFreeStyleProjectWithWorkspaceFiles("pmd.xml", "cpd.xml", "spotbugsXml.xml"); IssuesRecorder recorder = new IssuesRecorder(); recorder.setTools(createTool(new Pmd(), "**/pmd*.txt"), createTool(new Cpd(), "**/cpd*.txt"), createTool(new SpotBugs(), "**/spotbugs*.txt")); project.getPublishersList().add(recorder); Run<?, ?> build = buildSuccessfully(project); MetricsView view = (MetricsView) build.getAction(MetricsViewAction.class).getTarget(); assertThat(view.getSupportedMetrics()).contains( new MetricDefinition("ERRORS"), new MetricDefinition("WARNING_HIGH"), new MetricDefinition("WARNING_NORMAL"), new MetricDefinition("WARNING_LOW"), new MetricDefinition("AUTHORS"), new MetricDefinition("COMMITS") ); }
Example #8
Source File: FreeStylePipelineTest.java From blueocean-plugin with MIT License | 6 votes |
@Test public void findModernRun() throws Exception { FreeStyleProject freestyle = Mockito.spy(j.createProject(FreeStyleProject.class, "freestyle")); FreeStyleBuild build1 = Mockito.mock(FreeStyleBuild.class); FreeStyleBuild build2 = Mockito.mock(FreeStyleBuild.class); Mockito.when(build1.getParent()).thenReturn(freestyle); Mockito.when(build1.getNextBuild()).thenReturn(build2); Mockito.when(build2.getParent()).thenReturn(freestyle); Mockito.when(build2.getPreviousBuild()).thenReturn(build1); RunList<FreeStyleBuild> runs = RunList.fromRuns(Arrays.asList(build1, build2)); Mockito.doReturn(runs).when(freestyle).getBuilds(); Mockito.doReturn(build2).when(freestyle).getLastBuild(); FreeStylePipeline freeStylePipeline = (FreeStylePipeline) BluePipelineFactory.resolve(freestyle); assertNotNull(freeStylePipeline); BlueRun blueRun = freeStylePipeline.getLatestRun(); assertNotNull(blueRun); Links links = blueRun.getLinks(); assertNotNull(links); assertNotNull(links.get("self")); }
Example #9
Source File: WorkSpaceZipperTest.java From aws-lambda-jenkins-plugin with MIT License | 6 votes |
@Test public void testGetZipFileNotExists() throws Exception { FreeStyleProject p = j.createFreeStyleProject(); p.scheduleBuild2(0).get(); JenkinsLogger logger = new JenkinsLogger(System.out); WorkSpaceZipper workSpaceZipper = new WorkSpaceZipper(p.getSomeWorkspace(), logger); try { workSpaceZipper.getZip("echo.zip"); fail("Expected LambdaDeployException."); } catch (LambdaDeployException lde){ assertEquals("Could not find zipfile or folder.", lde.getMessage()); } }
Example #10
Source File: DockerComputerConnectorTest.java From docker-plugin with MIT License | 6 votes |
protected void should_connect_agent(DockerTemplate template) throws IOException, ExecutionException, InterruptedException, TimeoutException { // FIXME on CI windows nodes don't have Docker4Windows Assume.assumeFalse(SystemUtils.IS_OS_WINDOWS); String dockerHost = SystemUtils.IS_OS_WINDOWS ? "tcp://localhost:2375" : "unix:///var/run/docker.sock"; DockerCloud cloud = new DockerCloud(cloudName, new DockerAPI(new DockerServerEndpoint(dockerHost, null)), Collections.singletonList(template)); j.jenkins.clouds.replaceBy(Collections.singleton(cloud)); final FreeStyleProject project = j.createFreeStyleProject("test-docker-ssh"); project.setAssignedLabel(Label.get(LABEL)); project.getBuildersList().add(new Shell("whoami")); final QueueTaskFuture<FreeStyleBuild> scheduledBuild = project.scheduleBuild2(0); try { final FreeStyleBuild build = scheduledBuild.get(60L, TimeUnit.SECONDS); Assert.assertTrue(build.getResult() == Result.SUCCESS); Assert.assertTrue(build.getLog().contains("jenkins")); } finally { scheduledBuild.cancel(true); } }
Example #11
Source File: UsernamePasswordBindingTest.java From credentials-binding-plugin with MIT License | 6 votes |
@Test public void basics() throws Exception { String username = "bob"; String password = "s3cr3t"; UsernamePasswordCredentialsImpl c = new UsernamePasswordCredentialsImpl(CredentialsScope.GLOBAL, null, "sample", username, password); CredentialsProvider.lookupStores(r.jenkins).iterator().next().addCredentials(Domain.global(), c); FreeStyleProject p = r.createFreeStyleProject(); p.getBuildWrappersList().add(new SecretBuildWrapper(Collections.<Binding<?>>singletonList(new UsernamePasswordBinding("AUTH", c.getId())))); p.getBuildersList().add(Functions.isWindows() ? new BatchFile("echo %AUTH% > auth.txt") : new Shell("echo $AUTH > auth.txt")); r.configRoundtrip(p); SecretBuildWrapper wrapper = p.getBuildWrappersList().get(SecretBuildWrapper.class); assertNotNull(wrapper); List<? extends MultiBinding<?>> bindings = wrapper.getBindings(); assertEquals(1, bindings.size()); MultiBinding<?> binding = bindings.get(0); assertEquals(c.getId(), binding.getCredentialsId()); assertEquals(UsernamePasswordBinding.class, binding.getClass()); assertEquals("AUTH", ((UsernamePasswordBinding) binding).getVariable()); FreeStyleBuild b = r.buildAndAssertSuccess(p); r.assertLogNotContains(password, b); assertEquals(username + ':' + password, b.getWorkspace().child("auth.txt").readToString().trim()); assertEquals("[AUTH]", b.getSensitiveBuildVariables().toString()); }
Example #12
Source File: WebhookJobPropertyIT.java From office-365-connector-plugin with Apache License 2.0 | 6 votes |
@Test public void testDataCompatibility() throws Exception { // given FreeStyleProject foo = (FreeStyleProject) rule.jenkins.createProjectFromXML( "bar", getClass().getResourceAsStream("WebhookJobProperty/freestyleold1.xml") ); // when WebhookJobProperty webhookJobProperty = foo.getProperty(WebhookJobProperty.class); assertThat(webhookJobProperty.getWebhooks()).isNotEmpty(); // then rule.assertBuildStatusSuccess(foo.scheduleBuild2(0, new Cause.UserIdCause()).get()); }
Example #13
Source File: PushBuildActionTest.java From gitlab-plugin with GNU General Public License v2.0 | 6 votes |
@Test public void build() throws IOException { try { FreeStyleProject testProject = jenkins.createFreeStyleProject(); when(trigger.getTriggerOpenMergeRequestOnPush()).thenReturn(TriggerOpenMergeRequest.never); testProject.addTrigger(trigger); exception.expect(HttpResponses.HttpResponseException.class); new PushBuildAction(testProject, getJson("PushEvent.json"), null).execute(response); } finally { ArgumentCaptor<PushHook> pushHookArgumentCaptor = ArgumentCaptor.forClass(PushHook.class); verify(trigger).onPost(pushHookArgumentCaptor.capture()); assertThat(pushHookArgumentCaptor.getValue().getProject(), is(notNullValue())); assertThat(pushHookArgumentCaptor.getValue().getProject().getWebUrl(), is(notNullValue())); assertThat(pushHookArgumentCaptor.getValue().getUserUsername(), is(notNullValue())); assertThat(pushHookArgumentCaptor.getValue().getUserUsername(), containsString("jsmith")); } }
Example #14
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 #15
Source File: CucumberLivingDocumentationIT.java From cucumber-living-documentation-plugin with MIT License | 6 votes |
@Test public void shouldGenerateLivingDocumentatationOnSlaveNode() throws Exception{ DumbSlave slave = jenkins.createOnlineSlave(); FreeStyleProject project = jenkins.createFreeStyleProject("test"); project.setAssignedNode(slave); SingleFileSCM scm = new SingleFileSCM("asciidoctor.json", CucumberLivingDocumentationIT.class.getResource("/json-output/asciidoctor/asciidoctor.json").toURI().toURL()); project.setScm(scm); CukedoctorPublisher publisher = new CukedoctorPublisher(null, FormatType.HTML, TocType.RIGHT, true, true, "Living Documentation",false,false,false,false,false); project.getPublishersList().add(publisher); project.save(); FreeStyleBuild build = jenkins.buildAndAssertSuccess(project); jenkins.assertLogContains("Format: html" + NEW_LINE + "Toc: right"+NEW_LINE + "Title: Living Documentation"+NEW_LINE+"Numbered: true"+NEW_LINE + "Section anchors: true", build); jenkins.assertLogContains("Found 4 feature(s)...",build); jenkins.assertLogContains("Documentation generated successfully!",build); Assert.assertTrue("It should run on slave",build.getBuiltOn().equals(slave)); }
Example #16
Source File: SeedJobTest.java From configuration-as-code-plugin with MIT License | 6 votes |
@Test @ConfiguredWithCode("SeedJobTest_withSecurityConfig.yml") @Envs( @Env(name = "SEED_JOB_FOLDER_FILE_PATH", value = ".") ) public void configure_seed_job_with_security_config() throws Exception { final Jenkins jenkins = Jenkins.get(); final GlobalJobDslSecurityConfiguration dslSecurity = GlobalConfiguration.all() .get(GlobalJobDslSecurityConfiguration.class); assertNotNull(dslSecurity); assertThat("ScriptSecurity", dslSecurity.isUseScriptSecurity(), is(false)); FreeStyleProject seedJobWithSecurityConfig = (FreeStyleProject) jenkins.getItem("seedJobWithSecurityConfig"); assertNotNull(seedJobWithSecurityConfig); assertTrue(seedJobWithSecurityConfig.isInQueue()); FreeStyleBuild freeStyleBuild = j.buildAndAssertSuccess(seedJobWithSecurityConfig); j.assertLogContains("Processing DSL script testJob2.groovy", freeStyleBuild); j.assertLogContains("Added items:", freeStyleBuild); j.assertLogContains("GeneratedJob{name='testJob2'}", freeStyleBuild); }
Example #17
Source File: DryITest.java From warnings-ng-plugin with MIT License | 6 votes |
/** * Verifies that the right amount of duplicate code warnings are detected. */ @Test public void shouldHaveDuplicateCodeWarnings() { FreeStyleProject project = createFreeStyleProjectWithWorkspaceFiles(CPD_REPORT); enableGenericWarnings(project, new Cpd()); AnalysisResult result = scheduleBuildAndAssertStatus(project, Result.SUCCESS); assertThat(result).hasTotalSize(20); assertThat(result).hasQualityGateStatus(QualityGateStatus.INACTIVE); Run<?, ?> build = result.getOwner(); TableModel table = getDryTableModel(build); assertThatColumnsAreCorrect(table.getColumns()); table.getRows().stream() .map(row -> (DuplicationRow) row) .forEach(row -> assertThat(row.getSeverity()).contains("LOW")); }
Example #18
Source File: QueuesTest.java From jenkins-client-java with MIT License | 6 votes |
@Test public void getItems() throws IOException { Queue queue = queues.getItems(); assertNotNull(queue.getItems()); assertEquals(0, queue.getItems().size()); j.jenkins.setNumExecutors(0); FreeStyleProject project = j.createFreeStyleProject(); project.scheduleBuild2(0); queue = queues.getItems(); List<QueueItem> items = queue.getItems(); assertEquals(1, items.size()); QueueItem firstItem = items.get(0); int firstItemId = firstItem.getId(); assertNotNull(queues.getItem(firstItemId)); queues.cancelItem(firstItemId); assertEquals(0, queues.getItems().getItems().size()); }
Example #19
Source File: MultiBranchTest.java From blueocean-plugin with MIT License | 6 votes |
@Test public void resolveMbpLink() throws Exception { WorkflowMultiBranchProject mp = j.jenkins.createProject(WorkflowMultiBranchProject.class, "p"); FreeStyleProject f = j.jenkins.createProject(FreeStyleProject.class, "f"); 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(); j.waitUntilNoActivity(); Assert.assertEquals("/blue/rest/organizations/jenkins/pipelines/p/",LinkResolver.resolveLink(mp).getHref()); Assert.assertEquals("/blue/rest/organizations/jenkins/pipelines/p/branches/master/",LinkResolver.resolveLink(mp.getBranch("master")).getHref()); Assert.assertEquals("/blue/rest/organizations/jenkins/pipelines/p/branches/feature%252Fux-1/",LinkResolver.resolveLink(mp.getBranch("feature%2Fux-1")).getHref()); Assert.assertEquals("/blue/rest/organizations/jenkins/pipelines/p/branches/feature2/",LinkResolver.resolveLink(mp.getBranch("feature2")).getHref()); Assert.assertEquals("/blue/rest/organizations/jenkins/pipelines/f/",LinkResolver.resolveLink(f).getHref()); }
Example #20
Source File: GHPullRequestSubscriberTest.java From github-integration-plugin with MIT License | 6 votes |
@Test public void shouldTriggerJobOnPullRequestOpen() throws Exception { when(trigger.getRepoFullName(any(AbstractProject.class))).thenReturn(create(REPO_URL_FROM_PAYLOAD)); when(trigger.getTriggerMode()).thenReturn(GitHubPRTriggerMode.HEAVY_HOOKS); FreeStyleProject job = jenkins.createFreeStyleProject(); job.addProperty(new GithubProjectProperty(REPO_URL_FROM_PAYLOAD)); job.addTrigger(trigger); new GHPullRequestSubscriber().onEvent(new GHSubscriberEvent( "", GHEvent.PULL_REQUEST, classpath("payload/pull_request.json")) ); verify(trigger).queueRun(eq(job), eq(1)); }
Example #21
Source File: ReferenceFinderITest.java From warnings-ng-plugin with MIT License | 6 votes |
/** * Checks if the reference is taken from the last successful build and therefore returns an unstable in the end. */ @Test public void shouldCreateUnstableResultWithIgnoredUnstableInBetween() { // #1 SUCCESS FreeStyleProject project = createJob(JOB_NAME, "eclipse2Warnings.txt"); enableWarnings(project, recorder -> recorder.addQualityGate(3, QualityGateType.NEW, QualityGateResult.UNSTABLE)); Run<?, ?> expectedReference = scheduleBuildAndAssertStatus(project, Result.SUCCESS, analysisResult -> assertThat(analysisResult).hasTotalSize(2) .hasNewSize(0) .hasQualityGateStatus(QualityGateStatus.PASSED)).getOwner(); // #2 UNSTABLE cleanAndCopy(project, "eclipse6Warnings.txt"); scheduleBuildAndAssertStatus(project, Result.UNSTABLE, analysisResult -> assertThat(analysisResult).hasTotalSize(6) .hasNewSize(4) .hasQualityGateStatus(QualityGateStatus.WARNING)); // #3 UNSTABLE (Reference #1) cleanAndCopy(project, "eclipse8Warnings.txt"); scheduleBuildAndAssertStatus(project, Result.UNSTABLE, analysisResult -> assertThat(analysisResult) .hasTotalSize(8) .hasNewSize(6) .hasQualityGateStatus(QualityGateStatus.WARNING) .hasReferenceBuild(Optional.of(expectedReference))); }
Example #22
Source File: QualityGateITest.java From warnings-ng-plugin with MIT License | 5 votes |
/** * Tests if the build is considered unstable when its defined threshold for new issues with low severity is * reached. */ @Test public void shouldBeUnstableWhenUnstableNewLowIsReached() { FreeStyleProject project = createFreeStyleProject(); enableAndConfigureCheckstyle(project, recorder -> recorder.setUnstableNewLow(3)); runJobTwice(project, Result.UNSTABLE); }
Example #23
Source File: QualityGateITest.java From warnings-ng-plugin with MIT License | 5 votes |
/** * Tests if the build is considered unstable when its defined threshold for delta with normal severity is reached. */ @Test public void shouldBeUnstableWhenUnstableDeltaNormalIsReachedNew() { FreeStyleProject project = createFreeStyleProject(); enableAndConfigureCheckstyle(project, recorder -> recorder.addQualityGate(2, QualityGateType.DELTA_NORMAL, QualityGateResult.UNSTABLE)); runJobTwice(project, Result.UNSTABLE); }
Example #24
Source File: FiltersITest.java From warnings-ng-plugin with MIT License | 5 votes |
/** * Tests the category and file expression filter by comparing the result with expected. */ @Test public void shouldFilterCheckStyleIssuesByCategoryAndFile() { Map<RegexpFilter, Integer[]> expectedLinesByFilter = setupCategoryFilterForCheckStyle(); for (Entry<RegexpFilter, Integer[]> entry : expectedLinesByFilter.entrySet()) { FreeStyleProject project = createFreeStyleProjectWithWorkspaceFiles("checkstyle-filtering.xml"); enableGenericWarnings(project, recorder -> recorder.setFilters(toFilter(entry)), new CheckStyle()); buildAndVerifyResults(project, entry.getValue()); } }
Example #25
Source File: IntegrationTest.java From ec2-spot-jenkins-plugin with Apache License 2.0 | 5 votes |
protected List<QueueTaskFuture> getQueueTaskFutures(int count) throws IOException { final LabelAtom label = new LabelAtom("momo"); final List<QueueTaskFuture> rs = new ArrayList<>(); for (int i = 0; i < count; i++) { final FreeStyleProject project = j.createFreeStyleProject(); project.setAssignedLabel(label); project.getBuildersList().add(Functions.isWindows() ? new BatchFile("Ping -n " + JOB_SLEEP_TIME + " 127.0.0.1 > nul") : new Shell("sleep " + JOB_SLEEP_TIME)); rs.add(project.scheduleBuild2(0)); } return rs; }
Example #26
Source File: QualityGateITest.java From warnings-ng-plugin with MIT License | 5 votes |
/** * Tests if the build is considered unstable when its defined threshold for all issues is reached. */ @Test public void shouldBeUnstableWhenUnstableTotalAllIsReached() { FreeStyleProject project = createFreeStyleProject(); enableAndConfigureCheckstyle(project, recorder -> recorder.setUnstableTotalAll(11)); runJobTwice(project, Result.UNSTABLE); }
Example #27
Source File: QualityGateITest.java From warnings-ng-plugin with MIT License | 5 votes |
/** * Tests if the build is considered unstable when its defined threshold for all issues with high severity is * reached. */ @Test public void shouldBeUnstableWhenUnstableTotalErrorIsReachedNew() { FreeStyleProject project = createFreeStyleProject(); enableAndConfigureCheckstyle(project, recorder -> recorder.addQualityGate(6, QualityGateType.TOTAL_ERROR, QualityGateResult.UNSTABLE)); runJobTwice(project, Result.UNSTABLE); }
Example #28
Source File: QualityGateITest.java From warnings-ng-plugin with MIT License | 5 votes |
/** * Tests if the build is considered unstable when its defined threshold for all issues with normal severity is * reached. */ @Test public void shouldBeUnstableWhenUnstableTotalNormalIsReached() { FreeStyleProject project = createFreeStyleProject(); enableAndConfigureCheckstyle(project, recorder -> recorder.setUnstableTotalNormal(2)); runJobTwice(project, Result.UNSTABLE); }
Example #29
Source File: GitHubPRTriggerTest.java From github-integration-plugin with MIT License | 5 votes |
@Test public void shouldParseRepoNameFromProp() throws IOException, ANTLRException { FreeStyleProject p = j.createFreeStyleProject(); String org = "org"; String repo = "repo"; p.addProperty(new GithubProjectProperty(format("https://github.com/%s/%s", org, repo))); GitHubRepositoryName fullName = defaultGitHubPRTrigger().getRepoFullName(p); assertThat(fullName.getUserName(), equalTo(org)); assertThat(fullName.getRepositoryName(), equalTo(repo)); }
Example #30
Source File: AggregatedTestResultPublisherTest.java From junit-plugin with MIT License | 5 votes |
private void addFingerprinterToProject(FreeStyleProject project, String[] contents, String[] files) throws Exception { StringBuilder targets = new StringBuilder(); for (int i = 0; i < contents.length; i++) { String command = "echo $BUILD_NUMBER " + contents[i] + " > " + files[i]; project.getBuildersList().add(Functions.isWindows() ? new BatchFile(command) : new Shell(command)); targets.append(files[i]).append(','); } project.getPublishersList().add(new Fingerprinter(targets.toString())); }