Skip to content

Commit

Permalink
add parameter to jenkins::credentials to allow UUID to be set
Browse files Browse the repository at this point in the history
  • Loading branch information
madAndroid committed Aug 9, 2015
1 parent 03bdb74 commit 0343fe8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
9 changes: 6 additions & 3 deletions files/puppet_helper.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -162,18 +162,21 @@ class Actions {
/////////////////////////
// create credentials
/////////////////////////
void create_or_update_credentials(String username, String password, String description="", String private_key="") {
void create_or_update_credentials(String username, String password, String id="", String description="", String private_key="") {
def global_domain = Domain.global()
def credentials_store =
Jenkins.instance.getExtensionList(
'com.cloudbees.plugins.credentials.SystemCredentialsProvider'
)[0].getStore()

def credentials
if (id == "") {
id = null
}
if (private_key == "" ) {
credentials = new UsernamePasswordCredentialsImpl(
CredentialsScope.GLOBAL,
null,
id,
description,
username,
password
Expand All @@ -187,7 +190,7 @@ class Actions {
}
credentials = new BasicSSHUserPrivateKey(
CredentialsScope.GLOBAL,
null,
id,
username,
key_source,
password,
Expand Down
3 changes: 3 additions & 0 deletions manifests/credentials.pp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
$description = 'Managed by Puppet',
$private_key_or_path = '',
$ensure = 'present',
$uuid = '',
){
validate_string($ensure)

Expand All @@ -35,11 +36,13 @@
validate_string($password)
validate_string($description)
validate_string($private_key_or_path)
validate_string($uuid)
jenkins::cli::exec { "create-jenkins-credentials-${title}":
command => [
'create_or_update_credentials',
$title,
"'${password}'",
"'${uuid}'",
"'${description}'",
"'${private_key_or_path}'",
],
Expand Down

0 comments on commit 0343fe8

Please sign in to comment.