use of org.kohsuke.github.GHCreateRepositoryBuilder in project blueocean-plugin by jenkinsci.
the class GithubHelper method createEmptyRepository.
public String createEmptyRepository() throws IOException {
GitHub github = getGitHub();
String repositoryName = !useRandomSuffix ? this.repositoryName : this.repositoryName + "-" + getRandomSuffix();
try {
String repositoryFullname = organizationOrUsername + "/" + repositoryName;
GHRepository repositoryToDelete = github.getRepository(repositoryFullname);
repositoryToDelete.delete();
logger.info("Deleted repository " + repositoryFullname);
} catch (FileNotFoundException e) {
// fine to ignore error if the repo doesn't exist
}
GHCreateRepositoryBuilder builder;
if (organizationOrUsername.equals(github.getMyself().getLogin())) {
builder = github.createRepository(repositoryName);
} else {
try {
builder = github.getOrganization(organizationOrUsername).createRepository(repositoryName);
} catch (FileNotFoundException e) {
logger.error("found not find organization " + organizationOrUsername);
throw e;
}
}
githubRepository = builder.autoInit(true).create();
logger.info("Created repository " + githubRepository.getFullName());
return repositoryName;
}
Aggregations