Class CredentialsObtainer

java.lang.Object
jenkins.plugins.slack.CredentialsObtainer

public class CredentialsObtainer extends Object
  • Constructor Details

    • CredentialsObtainer

      public CredentialsObtainer()
  • Method Details

    • lookupCredentials

      public static org.jenkinsci.plugins.plaincredentials.StringCredentials lookupCredentials(String credentialId)
    • lookupCredentials

      public static org.jenkinsci.plugins.plaincredentials.StringCredentials lookupCredentials(String credentialId, Item item)
    • getTokenToUse

      public 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 token
      Parameters:
      credentialId - the id from the credential to be used
      item - 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