Class GitHubTokenCredentialsCreator

    • Field Detail

      • GH_PLUGIN_REQUIRED_SCOPE

        public static final List<String> GH_PLUGIN_REQUIRED_SCOPE
        Default scope required for this plugin. - admin:repo_hook - for managing hooks (read, write and delete old ones) - repo - to see private repos - repo:status - to manipulate commit statuses
    • Constructor Detail

      • GitHubTokenCredentialsCreator

        public GitHubTokenCredentialsCreator()
    • Method Detail

      • doFillCredentialsIdItems

        public ListBoxModel doFillCredentialsIdItems​(@QueryParameter
                                                     String apiUrl,
                                                     @QueryParameter
                                                     String credentialsId)
      • doCreateTokenByCredentials

        public FormValidation doCreateTokenByCredentials​(@QueryParameter
                                                         String apiUrl,
                                                         @QueryParameter
                                                         String credentialsId)
      • doCreateTokenByPassword

        public FormValidation doCreateTokenByPassword​(@QueryParameter
                                                      String apiUrl,
                                                      @QueryParameter
                                                      String login,
                                                      @QueryParameter
                                                      String password)
      • createToken

        public org.kohsuke.github.GHAuthorization createToken​(@NonNull
                                                              String username,
                                                              @NonNull
                                                              String password,
                                                              @Nullable
                                                              String apiUrl)
                                                       throws IOException
        Can be used to convert given login and password to GH personal token as more secured way to interact with api
        Parameters:
        username - gh login
        password - gh password
        apiUrl - gh api url. Can be null or empty to default
        Returns:
        personal token with requested scope
        Throws:
        IOException - when can't create token with given creds
      • createCredentials

        public com.cloudbees.plugins.credentials.common.StandardCredentials createCredentials​(@Nullable
                                                                                              String serverAPIUrl,
                                                                                              String token,
                                                                                              String username)
        Creates StringCredentials with previously created GH token. Adds them to domain extracted from server url (will be generated if no any exists before). Domain will have domain requirements consists of scheme and host from serverAPIUrl arg
        Parameters:
        serverAPIUrl - to add to domain with host and scheme requirement from this url
        token - GH Personal token
        username - used to add to description of newly created creds
        Returns:
        credentials object
        See Also:
        createCredentials(String, StandardCredentials)