Package org.kohsuke.github

Examples of org.kohsuke.github.GitHub


        }
    }

    public static GithubCurrentUserService current() {
        GithubAuthenticationToken auth = (GithubAuthenticationToken) SecurityContextHolder.getContext().getAuthentication();
        GitHub gh = auth.getGitHub();
        return new GithubCurrentUserService(gh);
    }
View Full Code Here


      public void put(String url) throws IOException {
        DBObject token = getToken(url);

        GithubAuthenticationToken auth = getAuthentication();
        GitHub gh = auth.getGitHub();
        String accessToken = getEncryptedToken(auth);

            if (token != null) {
                 getCollection().remove(token);
            }

            BasicDBObject doc = new BasicDBObject("user", gh.getMyself().getLogin()).append("access_token", accessToken).append("repo_url", url);
            getCollection().insert(doc);
      }
View Full Code Here

    }

    private String getGravatarUrl() {
        Authentication auth = SecurityContextHolder.getContext().getAuthentication();
        if (auth instanceof GithubAuthenticationToken) {
            GitHub gh = ((GithubAuthenticationToken) auth).getGitHub();
            try {
                return gh.getOrganization(orgName).getAvatarUrl();
            } catch (IOException e) {
                // try user
                try {
                    return gh.getUser(orgName).getAvatarUrl();
                } catch (IOException e1) {
                    // give up
                }
            }
        }
View Full Code Here

  public static Status ignore(GitHubIgnore annotation) {
    try {
      if (annotation == null) {
        return Status.NOT_TRACKING;
      }
      GitHub gitHub = GitHub.connect();
      GHRepository repository = gitHub.getRepository(annotation.repository());
      GHIssue issue = repository.getIssue(annotation.issue());
      if (issue != null && issue.getState() == GHIssueState.OPEN) {
        return Status.OPEN;
      } else {
        return Status.CLOSED;
View Full Code Here

            return ret;
        }

        public FormValidation doCreateApiToken(@QueryParameter("username") final String username, @QueryParameter("password") final String password) {
            try {
                GitHub gh = GitHub.connectToEnterprise(this.serverAPIUrl, username, password);
                GHAuthorization token = gh.createToken(Arrays.asList(GHAuthorization.REPO_STATUS, GHAuthorization.REPO), "Jenkins GitHub Pull Request Builder", null);
                return FormValidation.ok("Access token created: " + token.getToken());
            } catch (IOException ex) {
                return FormValidation.error("GitHub API token couldn't be created: " + ex.getMessage());
            }
        }
View Full Code Here

        public String getDisplayName() {
            return ""; // unused
        }

        public FormValidation doValidate(@QueryParameter String apiUrl, @QueryParameter String username, @QueryParameter String oauthAccessToken) throws IOException {
            GitHub gitHub;
            if (Util.fixEmpty(apiUrl) != null) {
                gitHub = GitHub.connectToEnterprise(apiUrl,oauthAccessToken);
            } else {
                gitHub = GitHub.connect(username,oauthAccessToken);
            }

            if (gitHub.isCredentialValid())
                return FormValidation.ok("Verified");
            else
                return FormValidation.error("Failed to validate the account");
        }
View Full Code Here

TOP

Related Classes of org.kohsuke.github.GitHub

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.