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 GithubBranchParameterDefinition("BRANCH", "master",githubRepository.getUrl())));
project.addProperty(new GithubRepoProperty(githubRepository.getUrl()));
project.addProperty(new BuildTypeProperty(SetupConfig.get().getDefaultBuildType()));
project.save();
folder.addItem(project);
folder.save();
return project;
} catch (IOException e) {
throw new RuntimeException(e);