Knife job start not displaying logs in jenkins?

I installed push-jobs feature on chef-server to run commands from workstation or Jenkins.

When I run the command from Jenkins “knife job start ‘chef-client’ <node_name>”, it is not displaying complete log like when I run “chef-client” on a node.

How to get the complete log in Jenkins console ?? Please help me with this.

Below is the log which i am getting,

C:\chef\chef-repo>knife job start ‘chef-client’ hybris-server
Started. Job ID: cdaf88e535736bbf816b1a46dd4c119d
.Running (1/1 in progress) …
…Complete.
command: chef-client
created_at: Mon, 16 Jan 2017 11:48:37 GMT
env:
id: cdaf88e535736bbf816b1a46dd4c119d
nodes:
succeeded: hybris-server
run_timeout: 3600
status: complete
updated_at: Mon, 16 Jan 2017 11:49:25 GMT

thanks,
umesha

If you want the job output, you’ll need to capture the Job ID and pass it into knife job output

Thanks @tomduffield its worked :slight_smile:

i was getting "ERROR: ArgumentError: wrong number of arguments (3 for 1…2)"
this link ‘https://github.com/chef/knife-push/issues/47’ helped me resolve above issue.

I want to get the JOB ID so that i can pass this JOB ID as a parameter in jenkins, please help ??

Regards,
Umesha

Without knowing specifically how you’re triggering the Job, the best I can say is to use awk (or something similar) to capture the output of the start command and regex capture the Job ID.

Thanks @tomduffield :slight_smile:
used batch cmd to capture the JOB ID.

But when i initiate the below cmd , i am receiving error… can you help me with this.

C:\chef\chef-repo>knife job output --channel stdout cdaf88e53573a83f3f491bcd9b447072 AT_Protogo 
ERROR: The object you are looking for could not be found
Response: <HTML><HEAD><TITLE>404 Not Found</TITLE></HEAD><BODY><H1>Not Found</H1>The requested document was not found on this server.<P><HR><ADDRESS>mochiweb+webmachine web server</ADDRESS></BODY></HTML>

What version of the Push Jobs Server and Push Jobs Client are you running? The job output command is only supported for Push 2.x.

@tomduffield push-jobs client version - 2.1.4 and server : opscode-push-jobs-server_2.1.1-1
job output worked for some builds, but suddenly it started showing the above message even after when chef-client succeeds.

  • Where exactly output logs will be stored in chef-server or chef-client ??

Hey,
So looking back I think I might have the answer. In your initial email I noticed that the --capture flag was missing from your command. That is required in order to tell the Push Jobs Client to send the logs to the Push Jobs Server (from where they are retrieved).

yes, I was using the same to capture the logs,

C:\chef\chef-repo>knife job start --capture 'chef-client' AT_DataHub-BackOffice Started. Job ID: cdaf88e53573e9484f70f577359ad714 .Running (1/1 in progress) ... .....................................Complete. capture_output: true command: chef-client created_at: Tue, 31 Jan 2017 16:13:32 GMT env: id: cdaf88e53573e9484f70f577359ad714 nodes: succeeded: AT_DataHub-BackOffice run_timeout: 3600 status: complete updated_at: Tue, 31 Jan 2017 16:14:16 GMT

C:\chef\chef-repo>knife job output --channel stdout cdaf88e53573e9484f70f577359ad714 AT_DataHub-BackOffice


C:\chef\chef-repo>

now i am not getting anything on the console :frowning:

Is your chef-client configured to send it’s logs to standard out?

Hi Tom,

Below is my push-client.rb file, kindly let me know if i am missing anything means.

Preformatted text# Generated by Chef

# Local modifications will be overwritten!

LC_ALL='en_US.UTF-8'

# Chef server connect options
chef_server_url   'URL'
node_name         'AT_DataHub-BackOffice'
client_key        'c:\chef\client.pem'
trusted_certs_dir 'c:\chef\trusted_certs'
verify_api_cert   true
ssl_verify_mode   :verify_peer
allow_unencrypted false

# The whitelist comes from node['push_jobs']['whitelist']
whitelist({"chef-client"=>"chef-client --force-formatter"})

# We're under runit, so don't output timestamp
Mixlib::Log::Formatter.show_time = true

Hi Tom,

I am able to get the logs on jenkins console but some issues here,
logs with small size (less than 100 lines) will be displayed in jenkins console but for bigger size logs i am getting below error.

knife job output --channel stdout cdaf88e53573d3c62aa12ccf6080315f AT_DataHub-BackOffice
ERROR: The object you are looking for could not be found
Response: <HTML><HEAD><TITLE>404 Not Found</TITLE></HEAD><BODY><H1>Not Found</H1>The requested document was not found on this server.<P><HR><ADDRESS>mochiweb+webmachine web server</ADDRESS></BODY></HTML>

is there any config settings i need to change to get the complete logs ??
tried all the possibilities but didnt work, kindly help me with this.