puppet-jenkins
puppet-jenkins copied to clipboard
Credentials
having trouble creating new credentials added to profile: jenkins::credentials { 'name-key': password => '', private_key_or_path => hiera('namekey_key'), }
error: Error: /Stage[main]/Profiles::Jenkins/Jenkins::Credentials[namekey-key]/Jenkins::Cli::Exec[create-jenkins-credentials-namekey-key]/Exec[create-jenkins-credentials-name-key]/unless: Check "$HELPER_CMD credential_info name-key | grep name-key" exceeded timeout
The problem comes from the jenkins-cli.jar
not handling correctly the private key argument when it is the content itself. It is due to the dash characters interpreted as option of the command line even if surrounded with quotes.
Debug: Exec[[email protected]](provider=shell): Executing '["/bin/sh", "-c", "/usr/bin/java -jar /usr/share/jenkins/jenkins-cli.jar -s http://127.0.0.1:8080 groovy /usr/share/jenkins/puppet_helper.groovy create_or_update_credentials [email protected] '' '' 'Managed by Puppet' '-----BEGIN'"]'
Debug: Executing '/bin/sh -c /usr/bin/java -jar /usr/share/jenkins/jenkins-cli.jar -s http://127.0.0.1:8080 groovy /usr/share/jenkins/puppet_helper.groovy create_or_update_credentials [email protected] '' '' 'Managed by Puppet' '-----BEGIN''
Debug: /Stage[main]/Main/Node[default]/Jenkins::Credentials[[email protected]]/Jenkins::Cli::Exec[[email protected]]/Exec[[email protected]]/returns: Sleeping for 10.0 seconds between tries
java -jar /usr/share/jenkins/jenkins-cli.jar -s "http://127.0.0.1:8080" groovy /usr/share/jenkins/puppet_helper.groovy create_or_update_credentials [email protected] '' '' 'Managed by Puppet' '-----BEGIN'
"-----BEGIN" is not a valid option
java -jar jenkins-cli.jar groovy [SCRIPT] [ARGUMENTS ...]
Executes the specified Groovy script.
SCRIPT : Script to be executed. File, URL or '=' to represent stdin.
ARGUMENTS : Command line arguments to pass into script.
I have opened a PR for comments that provides an alternative credentials type that should correctly handle cli authenication. https://github.com/jenkinsci/puppet-jenkins/pull/382