Azure-pipelines-tasks: [email protected] task returning buffer string representations instead of strings

Created on 27 Feb 2020  路  10Comments  路  Source: microsoft/azure-pipelines-tasks

Required Information

Entering this information will route you directly to the right team and expedite traction.

Question, Bug, or Feature?
Type: Bug

Enter Task Name: SSH

Environment

  • Server - Azure Pipelines or TFS on-premises? Azure Pipelines

    • If using Azure Pipelines, provide the account name, team project name, build definition name/build number:

      • Account name: charli-ai
      • Team project name: CharliAI
      • Build definition name/build number: Definition ID is 21, name is Backend release
  • Agent - Hosted or Private:

    • If using Hosted agent, provide agent queue name: fv-az215

Issue Description

The SSH@0 task no longer returns output streams (out/err) to the pipeline log. In its place are strings representing buffers, eg.

<Buffer 50 75 6c 6c 20 5b 2f 6f 70 74 2f 63 68 61 72 6c 69 5d 20 69 6d 61 67 65 73 20 66 6f 72 20 5b 53 74 61 67 69 6e 67 5d 20 65 6e 76 69 72 6f 6e 6d 65 6e ... >
<Buffer 46 72 6f 6d 20 73 73 68 2e 64 65 76 2e 61 7a 75 72 65 2e 63 6f 6d 3a 76 33 2f 63 68 61 72 6c 69 2d 61 69 2f 43 68 61 72 6c 69 41 49 2f 63 68 61 72 6c ... >
<Buffer 48 45 41 44 20 69 73 20 6e 6f 77 20 61 74 20 38 66 65 33 66 35 32 20 4d 65 72 67 65 64 20 50 52 20 35 30 39 3a 20 61 64 64 20 73 71 6c 20 73 63 72 69 ... >
<Buffer 41 6c 72 65 61 64 79 20 6f 6e 20 27 6d 61 73 74 65 72 27 0a>

This issue only started when the SSH task was updated to 0.165.0. The previous version (0.151.1) worked correctly.

Error logs

No error logs, but the task is behaving improperly.

Core bug

Most helpful comment

This has been fixed, let me know if you're still experiencing issues - sorry for the inconvenience

All 10 comments

I'm guessing the problem started in PR #12249, specifically here: https://github.com/microsoft/azure-pipelines-tasks/pull/12249/files#diff-2874428db3637eb5645ad56ab629b767L80

tl._writeLine called process.stdout.write, which can accept buffers. console.log() will just print the object.

I also had the problem - I have a work around. Just add a utf8 conversion to the output stream to ssh2helpers.js and it should work. This should be done for all SSH console.log messages.

         defer.resolve('0');
        }
    }).on('data', (data) => {            
        /* bad code below 
         * console.log(data);
         */
        console.log(data.toString('utf8'));

I just discovered that we started suffering from this regression between 2/21 & 2/24.

Does anyone have a good way to revert to the old task? My team is using this SSH task to support an electronic medical record that has code written before some of us were born, and this is forcing us to do some manual processes.

Unrelated --- I'm in my mid-30s.

This has been fixed, let me know if you're still experiencing issues - sorry for the inconvenience

Thanks for the quick fix @damccorm. Problem's resolved for us.

@damccorm Thanks for quick fix! The SSH task works for us now too.

I don't see any commits attached to this issue, that is why I would like to ask just this quick follow up question: were there some tests added to check for this so it won't happen in future? :) This was very critical bug for us, as we use output of SSH task to read Terraform plan phase output, when we deploy changes in our Azure infra.

@stazz , I noticed #12441, #12442, and #12443 were completed in short order during the issue; looking through those I did not find any tests.

@MarkIannucci Thanks for finding out the completed issues! Yeah I didn't see any tests either in those. I guess one just has to hope this same thing won't happen in future... 馃槺

Was this page helpful?
0 / 5 - 0 ratings