Interface Credentials


public interface Credentials
Credentials for remote Git access.
  • Method Details

    • getName

      String getName()
      The name for this set of credentials.
      Returns:
      Name
    • httpUserNamePassword

      void httpUserNamePassword(Object user, Object pass)
      Sets a http(s) username & password.

      Unsets SSH authentication.

      Parameters:
      user - Username. Anything that can lazy-evaluate to a string using Grolifant's stringize.
      pass - Password. Anything that can lazy-evaluate to a string using Grolifant's stringize.
    • httpToken

      void httpToken(Object token)
      Sets a token to be use for http(s) authentication.

      Typically a token from Github or Gitlab.

      Unsets SSH authentication.

      Parameters:
      token - Authentication token. Anything that can lazy-evaluate to a string using Grolifant's stringize.
    • sshKey

      void sshKey(Object privateKey)
      Sets the passphrase-less private key for SSH authentication.

      Unsets HTTP(s) authentication.

      Parameters:
      privateKey - Anything that can be evaluated to a string or a byte array.
    • sshKeyWithPassphrase

      void sshKeyWithPassphrase(Object privateKey, Object passphrase)
      Sets the private key for SSH authentication along with a passphrase.

      Unsets HTTP(s) authentication.

      Parameters:
      privateKey - Anything that can be evaluated to a string or a byte array.
      passphrase - Anything that can be evaluated to a string.
    • sshKeyFromFile

      void sshKeyFromFile(org.gradle.api.provider.Provider<File> location)
      Use a file for the private key.

      Unsets HTTP(s) authentication.

      Parameters:
      location - Location of file.
    • sshKeyFromFileWithPassphrase

      void sshKeyFromFileWithPassphrase(org.gradle.api.provider.Provider<File> location, Object passphrase)
      Use a file for the private along with a passphrase.

      Unsets HTTP(s) authentication.

      Parameters:
      location - Location of file.
      passphrase - Anything that can be evaluated to a string.
    • acceptAllSshHosts

      void acceptAllSshHosts()
      Accept all SSH hosts.

      This is a security hole, but it can be really useful for testing

    • acceptAllGitlabSshHosts

      void acceptAllGitlabSshHosts()
      Only accept host keys from Gitlab.
    • acceptAllGithubSshHosts

      void acceptAllGithubSshHosts()
      Only accept host keys from Github.
    • acceptSshHost

      void acceptSshHost(Object host, Object protocol, Object key)
      Accept host key.

      Call this multiple times to add multiple hosts. Calling any of the other accept* methods, will unset any of the hosts set in this way.

      Parameters:
      host - Anything convertible to a string.
      protocol - Anything convertible to a string.
      key - Anything convertible to a string or byte[]
    • getTransportCredentials

      org.gradle.api.provider.Provider<GitTransport> getTransportCredentials()
      A provider to the authentication methods that will be used.
      Returns:
      Authentication provider.