Пример #1
0
	public DynamicProject createNewProject(GHRepository githubRepository) {
		try {
			new GithubRepositoryService(githubRepository).linkProjectToCi();

			OrganizationContainer folder = this.organizationRepository.getOrCreateContainer(githubRepository.getOwner().getLogin());
			String projectName = githubRepository.getName();
			DynamicProject project = folder.createProject(DynamicProject.class, projectName);

			project.setDescription(format("<a href=\"%s\">%s</a>", githubRepository.getUrl(), githubRepository.getUrl()));
			project.setConcurrentBuild(true);
			if (StringUtils.isNotEmpty(SetupConfig.get().getLabel())) {
				project.setAssignedLabel(Jenkins.getInstance().getLabel(SetupConfig.get().getLabel()));
			}
			project.addProperty(new ParametersDefinitionProperty(new StringParameterDefinition("BRANCH", "master")));
			project.addProperty(new GithubRepoProperty(githubRepository.getUrl()));

			project.getPublishersList().add(new DotCiNotifier());
			project.save();
			folder.addItem(project);
			folder.save();
			return project;
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}
Пример #2
0
 @Test
 public void should_allow_permission_on_github_org_only_if_member() throws Exception {
   OrganizationContainer organizationContainer = Mockito.mock(OrganizationContainer.class);
   Mockito.when(organizationContainer.getName()).thenReturn("chairman-meow");
   DotCiACL acl = new DotCiACL(organizationContainer, "suryagaddipati", false);
   GithubAuthenticationToken githubAuthentication = getGithubAuthentication("chairman-meow");
   Assert.assertTrue(acl.hasPermission(githubAuthentication, Jenkins.READ));
 }
Пример #3
0
	public Iterable<DynamicProject> getProjectsForOrg(final OrganizationContainer organizationContainer) {
		return find(new BasicDBObject("parent", organizationContainer.getId()), castToDynamicProject(getTransformer(organizationContainer)));
	}
Пример #4
0
	public boolean projectExists(GHRepository repository) throws IOException {
		OrganizationContainer folder = this.organizationRepository.getOrganizationContainer(repository.getOwner().getLogin());
		return folder != null && folder.getItem(repository.getName()) != null;
	}