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)
-
Nested Class Summary
Nested classes/interfaces inherited from class hudson.model.Descriptor
Descriptor.FormException, Descriptor.PropertyType, Descriptor.Self
-
Field Summary
Modifier and TypeFieldDescriptionDefault scope required for this plugin.Fields inherited from class hudson.model.Descriptor
clazz
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptioncom.cloudbees.plugins.credentials.common.StandardCredentials
createCredentials
(String serverAPIUrl, String token, String username) CreatesStringCredentials
with previously created GH token.org.kohsuke.github.GHAuthorization
createToken
(String username, String password, String apiUrl) Can be used to convert given login and password to GH personal token as more secured way to interact with apidoCreateTokenByCredentials
(String apiUrl, String credentialsId) doCreateTokenByPassword
(String apiUrl, String login, String password) doFillCredentialsIdItems
(String apiUrl, String credentialsId) Methods inherited from class hudson.model.Descriptor
addHelpFileRedirect, bindJSON, calcAutoCompleteSettings, calcFillSettings, configure, configure, doHelp, find, find, findByDescribableClassName, findById, getCategory, getCheckMethod, getCheckUrl, getConfigFile, getConfigPage, getCurrentDescriptorByNameUrl, getDescriptorFullUrl, getDescriptorUrl, getGlobalConfigPage, getGlobalPropertyType, getHelpFile, getHelpFile, getHelpFile, getId, getJsonSafeClassName, getKlass, getPlugin, getPossibleViewNames, getPropertyType, getPropertyType, getPropertyTypeOrDie, getRequiredGlobalConfigPagePermission, getT, getViewPage, isInstance, isSubTypeOf, load, newInstance, newInstance, newInstancesFromHeteroList, newInstancesFromHeteroList, save, self, toArray, toList, toMap
-
Field Details
-
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
- Specified by:
getDescriptor
in interfaceDescribable<GitHubTokenCredentialsCreator>
-
getDisplayName
- Overrides:
getDisplayName
in classDescriptor<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 loginpassword
- gh passwordapiUrl
- 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) CreatesStringCredentials
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 urltoken
- GH Personal tokenusername
- used to add to description of newly created creds- Returns:
- credentials object
- See Also:
-