Java Code Examples for hudson.model.FreeStyleProject#getAction()
The following examples show how to use
hudson.model.FreeStyleProject#getAction() .
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: JobActionITest.java From warnings-ng-plugin with MIT License | 5 votes |
/** * Verifies that the side bar link is not missing if there are no issues in the latest build. */ @Test public void shouldHaveSidebarLinkEvenWhenLastActionHasNoResults() { FreeStyleProject project = createFreeStyleProjectWithWorkspaceFiles(ECLIPSE_LOG); enableWarnings(project, createTool(new Eclipse(), "**/no-valid-pattern")); AnalysisResult emptyResult = scheduleBuildAndAssertStatus(project, Result.SUCCESS); assertThat(emptyResult).hasTotalSize(0); JobAction jobAction = project.getAction(JobAction.class); assertThat(jobAction).isNotNull(); }
Example 2
Source File: JobActionITest.java From warnings-ng-plugin with MIT License | 5 votes |
private void assertActionProperties(final FreeStyleProject project, final Run<?, ?> build) { JobAction jobAction = project.getAction(JobAction.class); assertThat(jobAction).isNotNull(); ResultAction resultAction = build.getAction(ResultAction.class); assertThat(resultAction).isNotNull(); StaticAnalysisLabelProvider labelProvider = new Eclipse().getLabelProvider(); assertThat(jobAction.getDisplayName()).isEqualTo(labelProvider.getLinkName()); assertThat(jobAction.getTrendName()).isEqualTo(labelProvider.getTrendName()); assertThat(jobAction.getUrlName()).isEqualTo(labelProvider.getId()); assertThat(jobAction.getOwner()).isEqualTo(project); assertThat(jobAction.getIconFileName()).endsWith(labelProvider.getSmallIconUrl()); }
Example 3
Source File: GitHubPRTriggerTest.java From github-integration-plugin with MIT License | 5 votes |
/** * Snapshot of files before Branch trigger refactoring. */ @LocalData @Test public void ensureOldValid() { final TopLevelItem item = j.getInstance().getItem("test-job"); assertThat(item, notNullValue()); final FreeStyleProject project = (FreeStyleProject) item; final GitHubPRRepository prRepository = project.getAction(GitHubPRRepository.class); assertThat(project, notNullValue()); assertThat(prRepository.getFullName(), is("KostyaSha-auto/test")); final Map<Integer, GitHubPRPullRequest> pulls = prRepository.getPulls(); assertThat(pulls.size(), is(1)); final GitHubPRPullRequest pullRequest = pulls.get(1); assertThat(pullRequest, notNullValue()); assertThat(pullRequest.getTitle(), is("Update README.md")); assertThat(pullRequest.getHeadRef(), is("KostyaSha-auto-patch-1")); assertThat(pullRequest.isMergeable(), is(true)); assertThat(pullRequest.getBaseRef(), is("master")); assertThat(pullRequest.getUserLogin(), is("KostyaSha-auto")); assertThat(pullRequest.getSourceRepoOwner(), is("KostyaSha-auto")); assertThat(pullRequest.getLabels(), Matchers.<String>empty()); final GitHubPRTrigger trigger = project.getTrigger(GitHubPRTrigger.class); assertThat(trigger, notNullValue()); assertThat(trigger.getTriggerMode(), is(CRON)); assertThat(trigger.getEvents(), hasSize(2)); assertThat(trigger.isPreStatus(), is(false)); assertThat(trigger.isCancelQueued(), is(false)); assertThat(trigger.isSkipFirstRun(), is(false)); }
Example 4
Source File: GitHubPRTriggerJRuleTest.java From github-integration-plugin with MIT License | 4 votes |
/** * Ensure that GitHubPRRepository can be created without remote connections. */ @Test public void repositoryInitialisationWhenProviderFails() throws Exception { final FreeStyleProject project = jRule.createProject(FreeStyleProject.class, "project"); project.addProperty(new GithubProjectProperty("https://github.com/KostyaSha/test-repo/")); final GitHubPRTrigger prTrigger = new GitHubPRTrigger("", HEAVY_HOOKS, emptyList()); prTrigger.setRepoProvider(new GitHubBranchTriggerJRuleTest.FailingGitHubRepoProvider()); project.addTrigger(prTrigger); project.save(); final FreeStyleProject freeStyleProject = (FreeStyleProject) jRule.getInstance().getItem("project"); final GitHubPRRepository repository = freeStyleProject.getAction(GitHubPRRepository.class); assertThat(repository, notNullValue()); }
Example 5
Source File: GitHubPRTriggerMockTest.java From github-integration-plugin with MIT License | 4 votes |
/** * loading old local state data, running trigger and checking that old disappeared and new appeared */ @LocalData @Test public void actualiseRepo() throws Exception { Thread.sleep(1000); FreeStyleProject project = (FreeStyleProject) jRule.getInstance().getItem("project"); assertThat(project, notNullValue()); GitHubPRTrigger trigger = project.getTrigger(GitHubPRTrigger.class); assertThat(trigger, notNullValue()); GitHubRepositoryName repoFullName = trigger.getRepoFullName(); assertThat(repoFullName.getHost(), is("localhost")); assertThat(repoFullName.getUserName(), is("org")); assertThat(repoFullName.getRepositoryName(), is("old-repo")); GitHubPRRepository prRepository = project.getAction(GitHubPRRepository.class); assertThat(project, notNullValue()); assertThat(prRepository.getFullName(), is("org/old-repo")); assertThat(prRepository.getGithubUrl(), notNullValue()); assertThat(prRepository.getGithubUrl().toString(), is("https://localhost/org/old-repo/")); assertThat(prRepository.getGitUrl(), is("git://localhost/org/old-repo.git")); assertThat(prRepository.getSshUrl(), is("git@localhost:org/old-repo.git")); final Map<Integer, GitHubPRPullRequest> pulls = prRepository.getPulls(); assertThat(pulls.size(), is(1)); final GitHubPRPullRequest pullRequest = pulls.get(1); assertThat(pullRequest, notNullValue()); assertThat(pullRequest.getNumber(), is(1)); assertThat(pullRequest.getHeadSha(), is("65d0f7818009811e5d5eb703ebad38bbcc816b49")); assertThat(pullRequest.isMergeable(), is(true)); assertThat(pullRequest.getBaseRef(), is("master")); assertThat(pullRequest.getHtmlUrl().toString(), is("https://localhost/org/old-repo/pull/1")); // now new project.addProperty(new GithubProjectProperty("http://localhost/org/repo")); GitHubPluginRepoProvider repoProvider = new GitHubPluginRepoProvider(); repoProvider.setManageHooks(false); repoProvider.setRepoPermission(GHPermission.PULL); trigger.setRepoProvider(repoProvider); project.addTrigger(trigger); project.save(); // activate trigger jRule.configRoundtrip(project); trigger = ghPRTriggerFromJob(project); trigger.doRun(); jRule.waitUntilNoActivity(); assertThat(project.getBuilds(), hasSize(1)); repoFullName = trigger.getRepoFullName(); assertThat(repoFullName.getHost(), Matchers.is("localhost")); assertThat(repoFullName.getUserName(), Matchers.is("org")); assertThat(repoFullName.getRepositoryName(), Matchers.is("repo")); GitHubPRPollingLogAction logAction = project.getAction(GitHubPRPollingLogAction.class); assertThat(logAction, notNullValue()); assertThat(logAction.getLog(), containsString("Repository full name changed from 'org/old-repo' to 'org/repo'.\n")); assertThat(logAction.getLog(), containsString("Changing GitHub url from 'https://localhost/org/old-repo/' " + "to 'http://localhost/org/repo'.\n")); assertThat(logAction.getLog(), containsString("Changing Git url from 'git://localhost/org/old-repo.git' " + "to 'git://localhost/org/repo.git'.\n")); assertThat(logAction.getLog(), containsString("Changing SSH url from 'git@localhost:org/old-repo.git' " + "to 'git@localhost:org/repo.git'.\n")); assertThat(logAction.getLog(), containsString("Local settings changed, removing PRs in repository!")); }
Example 6
Source File: GitHubBranchTriggerJRuleTest.java From github-integration-plugin with MIT License | 4 votes |
/** * Ensure that GitHubPRRepository can be created without remote connections. */ @Test public void repositoryInitialisationWhenProviderFails() throws Exception { final FreeStyleProject project = jRule.createProject(FreeStyleProject.class, "project"); project.addProperty(new GithubProjectProperty("https://github.com/KostyaSha/test-repo/")); final GitHubBranchTrigger trigger = new GitHubBranchTrigger("", HEAVY_HOOKS, emptyList()); trigger.setRepoProvider(new FailingGitHubRepoProvider()); project.addTrigger(trigger); project.save(); final FreeStyleProject freeStyleProject = (FreeStyleProject) jRule.getInstance().getItem("project"); final GitHubBranchRepository repository = freeStyleProject.getAction(GitHubBranchRepository.class); assertThat(repository, notNullValue()); }
Example 7
Source File: GitHubBranchTriggerTest.java From github-integration-plugin with MIT License | 4 votes |
@LocalData @Test public void someTest() throws Exception { FreeStyleProject prj = jRule.createFreeStyleProject("project"); prj.addProperty(new GithubProjectProperty("http://localhost/org/repo")); final List<GitHubBranchEvent> events = new ArrayList<>(); events.add(new GitHubBranchCreatedEvent()); events.add(new GitHubBranchHashChangedEvent()); final GitHubBranchTrigger trigger = new GitHubBranchTrigger("", CRON, events); prj.addTrigger(trigger); prj.save(); // activate trigger jRule.configRoundtrip(prj); final GitHubBranchTrigger branchTrigger = prj.getTrigger(GitHubBranchTrigger.class); assertThat(branchTrigger.getRemoteRepository(), notNullValue()); GitHubBranchRepository localRepo = prj.getAction(GitHubBranchRepository.class); assertThat(localRepo, notNullValue()); assertThat(localRepo.getBranches().size(), is(2)); assertThat(localRepo.getBranches(), hasKey("for-removal")); assertThat(localRepo.getBranches(), hasKey("should-change")); GitHubBranch shouldChange = localRepo.getBranches().get("should-change"); assertThat(shouldChange.getCommitSha(), is("6dcb09b5b57875f334f61aebed695e2e4193ffbb")); // only single branch should change in local repo branchTrigger.doRun("should-change"); jRule.waitUntilNoActivity(); assertThat(prj.getBuilds(), hasSize(1)); FreeStyleBuild lastBuild = prj.getLastBuild(); GitHubBranchCause cause = lastBuild.getCause(GitHubBranchCause.class); assertThat(cause, notNullValue()); assertThat(cause.getCommitSha(), is("6dcb09b5b57875f334f61aebed695e2e4193ffgg")); assertThat(cause.getBranchName(), is("should-change")); localRepo = prj.getAction(GitHubBranchRepository.class); assertThat(localRepo, notNullValue()); assertThat(localRepo.getBranches().size(), is(2)); assertThat(localRepo.getBranches(), hasKey("for-removal")); assertThat(localRepo.getBranches(), hasKey("should-change")); shouldChange = localRepo.getBranches().get("should-change"); assertThat(shouldChange.getCommitSha(), is("6dcb09b5b57875f334f61aebed695e2e4193ffgg")); // and now full trigger run() branchTrigger.doRun(); jRule.waitUntilNoActivity(); assertThat(prj.getBuilds(), hasSize(2)); lastBuild = prj.getLastBuild(); assertThat(lastBuild, notNullValue()); cause = lastBuild.getCause(GitHubBranchCause.class); assertThat(cause, notNullValue()); assertThat(cause.getCommitSha(), is("6dcb09b5b57875f334f61aebed695e2e4193db5e")); assertThat(cause.getBranchName(), is("new-branch")); localRepo = prj.getAction(GitHubBranchRepository.class); assertThat(localRepo.getBranches().size(), is(2)); assertThat(localRepo.getBranches(), not(hasKey("for-removal"))); assertThat(localRepo.getBranches(), hasKey("should-change")); shouldChange = localRepo.getBranches().get("should-change"); assertThat(shouldChange.getCommitSha(), is("6dcb09b5b57875f334f61aebed695e2e4193ffgg")); assertThat(localRepo.getBranches(), hasKey("new-branch")); GitHubBranch branch = localRepo.getBranches().get("new-branch"); assertThat(branch.getCommitSha(), is("6dcb09b5b57875f334f61aebed695e2e4193db5e")); }
Example 8
Source File: GitHubPRTriggerMockTest.java From github-integration-plugin with MIT License | 3 votes |
@LocalData @Test public void badStatePR() throws InterruptedException, IOException { final TopLevelItem item = jRule.getInstance().getItem("test-job"); assertThat(item, notNullValue()); final FreeStyleProject project = (FreeStyleProject) item; GitHubPRRepository prRepository = project.getAction(GitHubPRRepository.class); assertThat(project, notNullValue()); assertThat(prRepository.getFullName(), is("org/repo")); final Map<Integer, GitHubPRPullRequest> pulls = prRepository.getPulls(); assertThat(pulls.size(), is(1)); final GitHubPRPullRequest pullRequest = pulls.get(1); assertThat(pullRequest, notNullValue()); assertThat(pullRequest.isInBadState(), is(true)); final GitHubPRTrigger trigger = project.getTrigger(GitHubPRTrigger.class); assertThat(trigger, notNullValue()); trigger.doRun(); GitHubPRPollingLogAction logAction = project.getAction(GitHubPRPollingLogAction.class); assertThat(logAction, notNullValue()); assertThat(logAction.getLog(), containsString("ERROR: local PR [#1 new-feature] is in bad state")); trigger.doRun(); logAction = project.getAction(GitHubPRPollingLogAction.class); assertThat(logAction.getLog(), not(containsString("ERROR: local PR [#1 new-feature] is in bad state"))); assertThat(logAction.getLog(), containsString("PR [#1 new-feature] not changed")); }