Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question/Bug: how does one get the stderr output? #331

Open
Adnn opened this issue Jun 25, 2021 · 1 comment
Open

Question/Bug: how does one get the stderr output? #331

Adnn opened this issue Jun 25, 2021 · 1 comment

Comments

@Adnn
Copy link

Adnn commented Jun 25, 2021

I am trying to capture both stderr and stdout of my job, to output to stdout.
(I am yet another Docker user ; )

I could not find instructions in the current doc, but have been following this comment: #182 (comment)

Now my jobber file is as follows

version: 1.4

resultSinks:
  - &stdoutSink
    type: stdout
    data: [stdout, stderr]

jobs:
  ExampleJob:
    cmd: /jobbercommand.sh
    time: '*/5 * * * * *'
    notifyOnSuccess: [*stdoutSink]
    notifyOnError: [*stdoutSink]

jobbercommand.sh simply run a python3 scripts which outputs two different lines, one to stdout, one to stderr.
In the current terminal output, I can only see the output the script made to stdout.

jobberuser: /jobbercommand.sh {
	"fate": 0,
	"job": {
		"command": "/jobbercommand.sh",
		"name": "ExampleJob",
		"status": "Good",
		"time": "*/5 * * * * *"
	},
	"startTime": 1624608890,
	"stderr": "Stdout message from Python.\n",
	"stdout": "Stdout message from Python.\n",
	"succeeded": true,
	"user": "jobberuser",
	"version": "1.4"
}

(This got me thinking for hours that jobber was not working, since my initial script only wrote to stderr: all I saw was a "blank" output from jobber, thinking the script never run and not having any message to help me debug appart from the return code).

Is it not the way to write a jobber file which captures both stderr and stdout and redirect the result to current terminal stdout?

Thank you for reading!


Edit: for completeness, the Python script

#!/usr/bin/env python3

import sys

if __name__ == "__main__":
    print("Stdout message from Python.")
    print("Stderr message from Python.", file=sys.stderr)
@Pigpocket
Copy link

Pigpocket commented Jul 12, 2021

I am also having this problem trying to capture the output of my jobber script, which at this point is just an echo command to make sure I can get it to work. The format of the .jobber file in the documentation is a bit different than what's actually in the file when I enter a bash terminal inside my docker container. This is what I set up initially, which I can confirm runs:

[jobs]
- name: ExampleScript
  cmd: /home/jobberuser/example-scheduled-task.sh
  time: '*'

Below is an attempt to separate out the resultsSinks into their own section. This fails with a "Failed to parse 'jobs' section: yaml: unmarshal errors: line 6: cannot unmarshal !!seq into bool"

[jobs]
- name: ExampleScript
  cmd: /home/jobberuser/example-scheduled-task.sh
  time: '*'
  notifyOnSuccess:
    - *stdoutSink
- resultSinks:
    - &stdoutSink
      type: stdout
      data:
        - stdout
        - stderr

The documentation seems to suggest that I don't need to use a separate resultSinks section, but the below fails with a similar error:

jobs:
- name: ExampleScript
  cmd: /home/jobberuser/example-scheduled-task.sh
  time: '*'
  notifyOnSuccess:
    - type: stdout
      data:
        - stdout
        - stderr

Am I getting the syntax wrong?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants