Skip to content

Instantly share code, notes, and snippets.

@leitu
Created August 29, 2017 04:44
Show Gist options
  • Save leitu/b0f7bd849632eff1e7c287999e5252fb to your computer and use it in GitHub Desktop.
Save leitu/b0f7bd849632eff1e7c287999e5252fb to your computer and use it in GitHub Desktop.
jenkins_script env_name do
command <<-EOH.gsub(/^ {8}/, '')
import jenkins.model.*
import com.cloudbees.plugins.credentials.*
import com.cloudbees.plugins.credentials.domains.*
import com.cloudbees.jenkins.plugins.awscredentials.*
domain = Domain.global()
store = Jenkins.instance.getExtensionList('com.cloudbees.plugins.credentials.SystemCredentialsProvider')[0].getStore()
credentials = new AWSCredentialsImpl(
CredentialsScope.GLOBAL,
"#{env_name}",
"#{aws_env['aws_access_key_id']}",
"#{aws_env['aws_secret_access_key']}",
"#{env_name} user"
)
store.addCredentials(domain, credentials)
EOH
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment