0

On Jenkinsfile I'm running few git commands using PowerShell, It seems command are successful but I get strange error. When I run these command directly with powershell I don't have any issues. Here is part of the code:

powershell '''
    Write-Output "git checkout -B ar/2020 ============="
    git checkout -B ar/2020
                        
    Write-Output "git reset --hard HEAD ============="
    git reset --hard HEAD
'''

Here is the output:

09:52:29  git checkout -B ar/2020 =============
09:52:37  Your branch is up to date with 'origin/ar/2020'.
09:52:37  powershell.exe : Reset branch 'ar/2020'
09:52:37  At C:\jenkins\workspace\TEST@tmp\durable-90a62004\powershellWrapper.ps1:3 char:1
09:52:37  + & powershell -NoProfile -NonInteractive -ExecutionPolicy Bypass -Comm ...
09:52:37  + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
09:52:37      + CategoryInfo          : NotSpecified: (Reset branch 'ar/2020':String) [], RemoteException
09:52:37      + FullyQualifiedErrorId : NativeCommandError
09:52:37   
09:52:37  git reset --hard HEAD =============
09:52:55  HEAD is now at af04dfe66cb Update list files
Epligam
  • 741
  • 2
  • 14
  • 36
  • 1
    Git outputs some messages to _stderr_, which are not actually errors. All PowerShell versions before 7.2 behaved badly when the _stderr_ stream was redirected (as done by Jenkins). It turned everything written to _stderr_ into PowerShell errors. If you can't upgrade, quick fix is to [prevent Git from writing to _stderr_](https://stackoverflow.com/a/59367795/7571258). And [more background reading](https://stackoverflow.com/a/59376457/7571258). – zett42 Dec 20 '22 at 10:46

0 Answers0