
// Configure global aws credentials
def aws_credentials = { instance, id, accessKey, secretKey, description ->
  // Retrieve the Global credential store
  def domain = com.cloudbees.plugins.credentials.domains.Domain.global()
  def store = instance.getExtensionList('com.cloudbees.plugins.credentials.SystemCredentialsProvider')[0].getStore()

  // Create the AWS credential
  def my_creds = new com.cloudbees.jenkins.plugins.awscredentials.AWSCredentialsImpl(
    com.cloudbees.plugins.credentials.CredentialsScope.GLOBAL,
    id,
    accessKey,
    secretKey,
    description,
    '',
    ''
  )

  store.addCredentials(domain, my_creds)
}

