Running into another issue with Jenkins…
Recipe: mycompany-jenkins::bel_master
* jenkins_plugin[credentials] action install (up to date)
* jenkins_plugin[ssh-credentials] action install (up to date)
* jenkins_plugin[ssh-slaves] action install (up to date)
* jenkins_command[safe-restart] action nothing (skipped due to action :nothing)
* jenkins_user[svcJenkins] action create (skipped due to not_if)
* ruby_block[set the security_enabled flag] action run
- execute the ruby block set the security_enabled flag
* jenkins_password_credentials[mycompanybot@mycompany.com] action create
Recipe: <Dynamically Defined Resource>
* remote_file[/var/chef/cache/jenkins-cli.jar] action create (up to date)
* file[/var/chef/cache/jenkins-key] action create (up to date)
(up to date)
Recipe: mycompany-jenkins::bel_master
* jenkins_password_credentials[mycompany] action create
================================================================================
Error executing action `create` on resource 'jenkins_password_credentials[mycompany]'
================================================================================
Mixlib::ShellOut::ShellCommandFailed
------------------------------------
Expected process to exit with [0], but received '1'
---- Begin output of "java" -jar "/var/chef/cache/jenkins-cli.jar" -s http://localhost:8080 groovy /tmp/groovy20161212-9645-1v2wzb ----
STDOUT:
STDERR: ERROR: Unexpected exception occurred while performing groovy command.
groovy.lang.MissingPropertyException: No such property: password for class: com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:53)
at org.codehaus.groovy.runtime.callsite.GetEffectivePojoPropertySite.getProperty(GetEffectivePojoPropertySite.java:66)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGetProperty(AbstractCallSite.java:296)
at RemoteClass.run(RemoteClass:37)
at groovy.lang.GroovyShell.runScriptOrMainOrTestOrRunnable(GroovyShell.java:263)
at groovy.lang.GroovyShell.run(GroovyShell.java:518)
at groovy.lang.GroovyShell.run(GroovyShell.java:497)
at hudson.cli.GroovyCommand.run(GroovyCommand.java:86)
at hudson.cli.CLICommand.main(CLICommand.java:257)
at hudson.cli.CliManagerImpl.main(CliManagerImpl.java:93)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at hudson.remoting.RemoteInvocationHandler$RPCRequest.perform(RemoteInvocationHandler.java:887)
at hudson.remoting.RemoteInvocationHandler$RPCRequest.call(RemoteInvocationHandler.java:862)
at hudson.remoting.RemoteInvocationHandler$RPCRequest.call(RemoteInvocationHandler.java:821)
at hudson.remoting.UserRequest.perform(UserRequest.java:153)
at hudson.remoting.UserRequest.perform(UserRequest.java:50)
at hudson.remoting.Request$2.run(Request.java:332)
at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:68)
at hudson.cli.CliManagerImpl$1.call(CliManagerImpl.java:64)
at hudson.remoting.CallableDecoratorAdapter.call(CallableDecoratorAdapter.java:18)
at hudson.remoting.CallableDecoratorList$1.call(CallableDecoratorList.java:21)
at jenkins.util.ContextResettingExecutorService$2.call(ContextResettingExecutorService.java:46)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
---- End output of "java" -jar "/var/chef/cache/jenkins-cli.jar" -s http://localhost:8080 groovy /tmp/groovy20161212-9645-1v2wzb ----
Ran "java" -jar "/var/chef/cache/jenkins-cli.jar" -s http://localhost:8080 groovy /tmp/groovy20161212-9645-1v2wzb returned 1
Cookbook Trace:
---------------
/var/chef/cache/cookbooks/jenkins/libraries/_executor.rb:84:in `execute!'
/var/chef/cache/cookbooks/jenkins/libraries/_executor.rb:137:in `groovy!'
/var/chef/cache/cookbooks/jenkins/libraries/credentials.rb:227:in `current_credentials'
/var/chef/cache/cookbooks/jenkins/libraries/credentials.rb:68:in `load_current_resource'
/var/chef/cache/cookbooks/jenkins/libraries/credentials_user.rb:37:in `load_current_resource'
/var/chef/cache/cookbooks/jenkins/libraries/credentials_password.rb:47:in `load_current_resource'
/var/chef/cache/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/runner.rb:78:in `run_action'
/var/chef/cache/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/runner.rb:106:in `block (2 levels) in converge'
/var/chef/cache/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/runner.rb:106:in `each'
/var/chef/cache/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/runner.rb:106:in `block in converge'
/var/chef/cache/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/runner.rb:105:in `converge'
Resource Declaration:
---------------------
suppressed sensitive resource output
Compiled Resource:
------------------
suppressed sensitive resource output
My code is as follows:
# Configure password and SSH credentials
credentials = jenkins_keys['password_credentials']
credentials.each do |credential|
jenkins_password_credentials credential['name'] do
id credential['id']
description credential['desc'] unless credential['desc'].nil?
password credential['password']
notifies :execute, 'jenkins_command[safe-restart]', :delayed
end
end
And the databag looks something like this:
"password_credentials": [
{
"name": "mycompanybot@mycompany.com",
"id": "6f71a8ef-5ac6-4335-a5c4-xx",
"password": "[REDACTED]",
"desc": "Password for mycompanybot on BitBucket"
},
{
"name": "mycompany",
"id": "114c4ccf-d70a-41a7-9e31-xx",
"password": "[REDACTED]",
"desc": "Password for mycompany on OSX slave node"
},
{
"name": "jenkins",
"id": "5123529a-1bcf-456e-a920-xx",
"password": "[REDACTED]",
"desc": "Password for jenkins on slave nodes"
}
],
I’m pretty confused as the first credential works fine, but the second one blows up. And it looks like it’s getting confused as to which type of credential it is based off of the Hudson error (“groovy.lang.MissingPropertyException: No such property: password for class: com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey”).
Getting rather frustrated here, I’ve run into so many different issues trying to get this configured through Chef.