0

I'm currently building a Pipeline to deploy my PHP Symfony Project from Dev Ops Repo to my Server. I use a SSH Task to execute the commands on the Server. The SSH Connection works fine, but some outputs of the executed commands are threaded as errors, like for git pull:

Starting: Run shell inline on remote machine
==============================================================================
Task         : SSH
Description  : Run shell commands or a script on a remote machine using SSH
Version      : 0.177.0
Author       : Microsoft Corporation
Help         : https://learn.microsoft.com/azure/devops/pipelines/tasks/deploy/ssh
==============================================================================
Trying to establish an SSH connection to ***@xxx
Successfully connected.
chmod +x ./sshscript_32bf87de-91b8-45b5-bae1-02400a139bfc
./sshscript_32bf87de-91b8-45b5-bae1-02400a139bfc
##[error]From vs-ssh.visualstudio.com:v3/xxx
 * branch            master     -> FETCH_HEAD

Already up-to-date.

##[error]Command failed with errors on remote machine.
Finishing: Run shell inline on remote machine

This is my Configuration:

trigger:
- master

pool:
  vmImage: 'ubuntu-latest'

steps:
- task: SSH@0
  displayName: 'Clean and Pull Git'
  continueOnError: false
  inputs:
    sshEndpoint: 'xxx'
    runOptions: inline
    inline: |-
      cd xxx
      git clean -xdf
      git pull origin master

How can I solve this Issue? (e.g. composer install has the same problem)

I know I could redirect stdout, but I want to keep the Output Messages

iF4yt
  • 1
  • 1
  • Hey @iF4yt, are you sure that they are *some* commands, or isn't there only the `git` commands? As far as I know, `git` command printed to `stderr` in general. To handle this, I use `$env:GIT_REDIRECT_STDERR = '2>&1'` for PowerShell scripts. Hope this helps. Check [here](https://stackoverflow.com/questions/34820975/git-clone-redirect-stderr-to-stdout-but-keep-errors-being-written-to-stderr) for more information. – Mar Tin Jan 17 '21 at 15:06
  • Hey @MarTin Thank you for the Tip! And yes. I'm sure that multiple Commands have this Problem. E,g, composer install: `##[error] - Installing composer/package-versions-deprecated (1.11.99.1): Extracting archive ##[error] - Installing symfony/flex (v1.11.0): Extracting archive ##[error] - Installing symfony/routing (v4.4.18): Extracting archive` – iF4yt Jan 17 '21 at 18:42

1 Answers1

0

You can try setting the failOnStdErr to false to slove this question.

Just like the following:

steps:
- task: SSH@0
  displayName: 'Clean and Pull Git'
  continueOnError: false
  inputs:
    sshEndpoint: 'xxx'
    runOptions: inline
    failOnStdErr: false
    inline: |-
      cd xxx
      git clean -xdf
      git pull origin master
Jane Ma-MSFT
  • 4,461
  • 1
  • 6
  • 12