Package jenkins.plugins.slack
Class CredentialsObtainer
java.lang.Object
jenkins.plugins.slack.CredentialsObtainer
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Item
getItemForCredentials
(org.jenkinsci.plugins.workflow.steps.StepContext context) Tries to obtain the proper Item object to provide to CredentialsProvider.static String
getTokenToUse
(String credentialId, Item item, String token) Attempts to obtain the credential with the providedId from the item's credential context, otherwise returns tokenstatic org.jenkinsci.plugins.plaincredentials.StringCredentials
lookupCredentials
(String credentialId) static org.jenkinsci.plugins.plaincredentials.StringCredentials
lookupCredentials
(String credentialId, Item item)
-
Constructor Details
-
CredentialsObtainer
public CredentialsObtainer()
-
-
Method Details
-
lookupCredentials
public static org.jenkinsci.plugins.plaincredentials.StringCredentials lookupCredentials(String credentialId) -
lookupCredentials
-
getTokenToUse
Attempts to obtain the credential with the providedId from the item's credential context, otherwise returns token- Parameters:
credentialId
- the id from the credential to be useditem
- the item with the context to obtain the credential from.token
- the fallback token- Returns:
- the obtained token
-
getItemForCredentials
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public static Item getItemForCredentials(org.jenkinsci.plugins.workflow.steps.StepContext context) Tries to obtain the proper Item object to provide to CredentialsProvider. Project works for freestyle jobs, the parent of the Run works for pipelines. In case the proper item cannot be found, null is returned, since when null is provided to CredentialsProvider, it will internally use Jenkins.getInstance() which effectively only allows global credentials.- Parameters:
context
- is a StepContext- Returns:
- the item to use for CredentialsProvider credential lookup
-