Class GitHubTokenCredentialsCreator

java.lang.Object
hudson.model.Descriptor<GitHubTokenCredentialsCreator>
org.jenkinsci.plugins.github.config.GitHubTokenCredentialsCreator
All Implemented Interfaces:
Describable<GitHubTokenCredentialsCreator>, Saveable, OnMaster

@Extension public class GitHubTokenCredentialsCreator extends Descriptor<GitHubTokenCredentialsCreator> implements Describable<GitHubTokenCredentialsCreator>
Helper class to convert username+password credentials or directly login+password to GH token and save it as token credentials with help of plain-credentials plugin
Since:
1.13.0
Author:
lanwen (Merkushev Kirill)
  • Field Details

    • 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 Details

    • GitHubTokenCredentialsCreator

      public GitHubTokenCredentialsCreator()
  • Method Details

    • getDescriptor

      public GitHubTokenCredentialsCreator getDescriptor()
      Specified by:
      getDescriptor in interface Describable<GitHubTokenCredentialsCreator>
    • getDisplayName

      public String getDisplayName()
      Overrides:
      getDisplayName in class Descriptor<GitHubTokenCredentialsCreator>
    • 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)