Azure-pipelines-agent: Show script output

Created on 7 May 2019  路  12Comments  路  Source: microsoft/azure-pipelines-agent

When curl runs in a script task, if it's the last command, its stdout output appears to get eaten. If there's an echo after the curl, output ends up in the logs.

Example build, example run. Only "checkpoint 3" shows any output.

This issue was moved by vtbassmatt from MicrosoftDocs/vsts-docs#4125.

Most helpful comment

@vtbassmatt commented on May 7, 2019, 12:28 PM UTC:

That's fascinating. It suggests that curl is buffering or something, and we're not receiving the output if it's the last thing before end of task. We will investigate.

All 12 comments

@vtbassmatt commented on May 2, 2019, 3:38 PM UTC:

All output to stdout and stderr ends up in the logs. If you have an example where this isn't happening, I'd be happy to take a look.

@mchelen commented on May 3, 2019, 3:52 PM UTC:

vtbassmatt Hmm maybe it's surpressing STDOUT when STDERR exists?
Here is an example pipeline, the "Register Snapshot" task looks like this:

- script: |
    curl -X PUT "http://localhost:9200/_snapshot/backups" -H "Content-Type:application/json" -d'{"type":"fs", "settings":{"location":"snapshots"}}'
  displayName: Register Snapshot

It should return {"acknowledged":true} or some error, but no output like this can be seen in the log.

@vtbassmatt commented on May 6, 2019, 8:12 PM UTC:

A successful PUT response doesn't have a body. Are you sure that's not just curl and your server behaving properly? I see in a previous step where you curl Google.com and it does correctly render both curl's downloading output and the response.

@mchelen commented on May 6, 2019, 10:59 PM UTC:

vtbassmatt Ok I switched it to a GET call. Something is still weird because the response is not shown for Snapshot Info 1, 2, or 4 but it is shown for Snapshot Info 3:
https://dev.azure.com/mchelen-test/example/_build/results?buildId=34
https://dev.azure.com/mchelen-test/_git/example?path=%2Fazure-pipelines.yml&version=GBmaster

@vtbassmatt commented on May 7, 2019, 12:28 PM UTC:

That's fascinating. It suggests that curl is buffering or something, and we're not receiving the output if it's the last thing before end of task. We will investigate.

this might be a task issue and not the agent since the agent is waiting for node.exe to exit not curl

Taking a look at this to see if I can repro

@mchelen can you confirm if you are still seeing this issue? If so, can we run another build on mchelen-test as the build logs seemed to have timed out and i can't see them. I have done some rudimentary tests and cannot reproduce the issue.

@jtpetty yup, it's still happening, i'm not sure if it's something odd about curl or what.

in this build: https://dev.azure.com/mchelen-test/example/_build/results?buildId=35
only __Snapshot Info 3__ shows the stdout from the curl command.

@mchelen - just a hunch, but can we try adding -sS to curl and see if that fixes it?

@mchelen - I believe I have tracked down this problem to an issue where if the last line of output does not end with \n, then that line is not echoed out to the console. I was able to repro this without curl, but rather this python command:

python -c "print('helloworld', end='')"

Can you confirm this command gives you the same symptom?

Closing as this issue was fixed, merged and released.

Was this page helpful?
0 / 5 - 0 ratings