public static GitHubBuilder fromProperties(Properties props) { GitHubBuilder self = new GitHubBuilder(); self.withOAuthToken(props.getProperty("oauth"), props.getProperty("login")); self.withPassword(props.getProperty("login"), props.getProperty("password")); self.withEndpoint(props.getProperty("endpoint", GitHub.GITHUB_URL)); return self; }
public static GitHubBuilder fromProperties(Properties props) { GitHubBuilder self = new GitHubBuilder(); self.withOAuthToken(props.getProperty("oauth"), props.getProperty("login")); self.withPassword(props.getProperty("login"), props.getProperty("password")); self.withEndpoint(props.getProperty("endpoint", GitHub.GITHUB_URL)); return self; }
public static GitHubBuilder fromProperties(Properties props) { GitHubBuilder self = new GitHubBuilder(); self.withOAuthToken(props.getProperty("oauth"), props.getProperty("login")); self.withPassword(props.getProperty("login"), props.getProperty("password")); self.withEndpoint(props.getProperty("endpoint", GitHub.GITHUB_URL)); return self; }
/** * Connects to GitHub Enterprise anonymously. * * All operations that requires authentication will fail. */ public static GitHub connectToEnterpriseAnonymously(String apiUrl) throws IOException { return new GitHubBuilder().withEndpoint(apiUrl).build(); }
/** * Connects to GitHub Enterprise anonymously. * * All operations that requires authentication will fail. */ public static GitHub connectToEnterpriseAnonymously(String apiUrl) throws IOException { return new GitHubBuilder().withEndpoint(apiUrl).build(); }
/** * Version that connects to GitHub Enterprise. * * @param apiUrl * The URL of GitHub (or GitHub enterprise) API endpoint, such as "https://api.github.com" or * "http://ghe.acme.com/api/v3". Note that GitHub Enterprise has <tt>/api/v3</tt> in the URL. * For historical reasons, this parameter still accepts the bare domain name, but that's considered deprecated. */ public static GitHub connectToEnterpriseWithOAuth(String apiUrl, String login, String oauthAccessToken) throws IOException { return new GitHubBuilder().withEndpoint(apiUrl).withOAuthToken(oauthAccessToken, login).build(); }
/** * Version that connects to GitHub Enterprise. * * @deprecated * Use with caution. Login with password is not a preferred method. */ public static GitHub connectToEnterprise(String apiUrl, String login, String password) throws IOException { return new GitHubBuilder().withEndpoint(apiUrl).withPassword(login, password).build(); }
/** * An offline-only {@link GitHub} useful for parsing event notification from an unknown source. * * All operations that require a connection will fail. * * @return An offline-only {@link GitHub}. */ public static GitHub offline() { try { return new GitHubBuilder() .withEndpoint("https://api.github.invalid") .withConnector(HttpConnector.OFFLINE) .build(); } catch (IOException e) { throw new IllegalStateException("The offline implementation constructor should not connect", e); } }
/** * Version that connects to GitHub Enterprise. * * @param apiUrl * The URL of GitHub (or GitHub enterprise) API endpoint, such as "https://api.github.com" or * "http://ghe.acme.com/api/v3". Note that GitHub Enterprise has <tt>/api/v3</tt> in the URL. * For historical reasons, this parameter still accepts the bare domain name, but that's considered deprecated. */ public static GitHub connectToEnterprise(String apiUrl, String oauthAccessToken) throws IOException { return new GitHubBuilder().withEndpoint(apiUrl).withOAuthToken(oauthAccessToken).build(); }
/** * Version that connects to GitHub Enterprise. * * @deprecated * Use with caution. Login with password is not a preferred method. */ public static GitHub connectToEnterprise(String apiUrl, String login, String password) throws IOException { return new GitHubBuilder().withEndpoint(apiUrl).withPassword(login, password).build(); }
/** * An offline-only {@link GitHub} useful for parsing event notification from an unknown source. * * All operations that require a connection will fail. * * @return An offline-only {@link GitHub}. */ public static GitHub offline() { try { return new GitHubBuilder() .withEndpoint("https://api.github.invalid") .withConnector(HttpConnector.OFFLINE) .build(); } catch (IOException e) { throw new IllegalStateException("The offline implementation constructor should not connect", e); } }
public static GitHub connectUsingOAuth(String githubServer, String oauthAccessToken) throws IOException { return new GitHubBuilder().withEndpoint(githubServer).withOAuthToken(oauthAccessToken).build(); } /**
/** * Version that connects to GitHub Enterprise. * * @param apiUrl * The URL of GitHub (or GitHub enterprise) API endpoint, such as "https://api.github.com" or * "http://ghe.acme.com/api/v3". Note that GitHub Enterprise has <tt>/api/v3</tt> in the URL. * For historical reasons, this parameter still accepts the bare domain name, but that's considered deprecated. */ public static GitHub connectToEnterpriseWithOAuth(String apiUrl, String login, String oauthAccessToken) throws IOException { return new GitHubBuilder().withEndpoint(apiUrl).withOAuthToken(oauthAccessToken, login).build(); }
public static GitHub connectUsingOAuth(String githubServer, String oauthAccessToken) throws IOException { return new GitHubBuilder().withEndpoint(githubServer).withOAuthToken(oauthAccessToken).build(); } /**
public static GitHub connectUsingOAuth(String githubServer, String oauthAccessToken) throws IOException { return new GitHubBuilder().withEndpoint(githubServer).withOAuthToken(oauthAccessToken).build(); } /**
public static DockerfileGitHubUtil initializeDockerfileGithubUtil(String gitApiUrl) throws IOException { if (gitApiUrl == null) { gitApiUrl = System.getenv("git_api_url"); if (gitApiUrl == null) { throw new IOException("No Git API URL in environment variables."); } } String token = System.getenv("git_api_token"); if (token == null) { log.error("Please provide GitHub token in environment variables."); System.exit(3); } GitHub github = new GitHubBuilder().withEndpoint(gitApiUrl) .withOAuthToken(token) .build(); github.checkApiUrlValidity(); GitHubUtil gitHubUtil = new GitHubUtil(github); return new DockerfileGitHubUtil(gitHubUtil); } }
public static GitHub connectToEnterprise(String apiUrl, String login, String password) throws IOException { return new GitHubBuilder().withEndpoint(apiUrl).withPassword(login, password).build(); }
/** * Can be used to convert given login and password to GH personal token as more secured way to interact with api * * @param username gh login * @param password gh password * @param apiUrl gh api url. Can be null or empty to default * * @return personal token with requested scope * @throws IOException when can't create token with given creds */ public GHAuthorization createToken(@Nonnull String username, @Nonnull String password, @Nullable String apiUrl) throws IOException { GitHub gitHub = new GitHubBuilder() .withEndpoint(defaultIfBlank(apiUrl, GITHUB_URL)) .withPassword(username, password) .build(); return gitHub.createToken( GH_PLUGIN_REQUIRED_SCOPE, format("Jenkins GitHub Plugin token (%s)", Jenkins.getInstance().getRootUrl()), Jenkins.getInstance().getRootUrl() ); }
@BeforeClass public void setUp() throws Exception { String gitApiUrl = System.getenv("git_api_url"); String token = System.getenv("git_api_token"); github = new GitHubBuilder().withEndpoint(gitApiUrl) .withOAuthToken(token) .build(); github.checkApiUrlValidity(); cleanBefore(); gitHubUtil = new GitHubUtil(github); GHOrganization org = github.getOrganization(ORG); GHRepository repo = org.createRepository(NAME) .description("Delete if this exists. If it exists, then an integration test crashed somewhere.") .private_(false) .create(); log.info("Initializing {}", repo.getFullName()); createdRepos.add(repo); repo.createContent("FROM " + IMAGE + ":test", "Integration Testing", "Dockerfile"); }
public void init(int pullRequestNumber, File projectBaseDir) { initGitBaseDir(projectBaseDir); try { GitHub github; if (config.isProxyConnectionEnabled()) { github = new GitHubBuilder().withProxy(config.getHttpProxy()).withEndpoint(config.endpoint()).withOAuthToken(config.oauth()).build(); } else { github = new GitHubBuilder().withEndpoint(config.endpoint()).withOAuthToken(config.oauth()).build(); } setGhRepo(github.getRepository(config.repository())); setPr(ghRepo.getPullRequest(pullRequestNumber)); LOG.info("Starting analysis of pull request: " + pr.getHtmlUrl()); myself = github.getMyself().getLogin(); loadExistingReviewComments(); patchPositionMappingByFile = mapPatchPositionsToLines(pr); } catch (IOException e) { LOG.debug("Unable to perform GitHub WS operation", e); throw MessageException.of("Unable to perform GitHub WS operation: " + e.getMessage()); } }