Created
August 29, 2017 04:44
-
-
Save leitu/b0f7bd849632eff1e7c287999e5252fb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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