code: private StandardCredentials createCredentials(@Nonnull String serverAPIUrl,
                                                    final StandardCredentials credentials) {
          URI serverUri = URI.create(defaultIfBlank(serverAPIUrl, GITHUB_URL));
  
          List<DomainSpecification> specifications = asList(
                  new SchemeSpecification(serverUri.getScheme()),
                  new HostnameSpecification(serverUri.getHost(), null)
          );
  
          final Domain domain = new Domain(serverUri.getHost(), "GitHub domain (autogenerated)", specifications);
          ACL.impersonate(ACL.SYSTEM, new Runnable() { // do it with system rights
              @Override
              public void run() {
                  try {
                      new SystemCredentialsProvider.StoreImpl().addDomain(domain, credentials);
                  } catch (IOException e) {
                      LOGGER.error("Can't add creds for domain", e);
                  }
              }
          });
  
          return credentials;
      }
docs: Saves given creds in jenkins for domain extracted from server api url
  
  @param serverAPIUrl to extract (and create if no any) domain
  @param credentials  creds to save
  
  @return saved creds