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

Publish to Azure DevOps Wiki fails with Error: spawn git ENOENT #738

Closed
ipavlovi opened this issue Jun 12, 2020 · 22 comments
Closed

Publish to Azure DevOps Wiki fails with Error: spawn git ENOENT #738

ipavlovi opened this issue Jun 12, 2020 · 22 comments
Assignees

Comments

@ipavlovi
Copy link

Release notes are successful generated but in the next step publish to Azure DevOps Wiki fails with following error:

Error: Error: spawn git ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:240:19)
    at onErrorNT (internal/child_process.js:415:16)
    at process._tickCallback (internal/process/next_tick.js:63:19)
    at Function.Module.runMain (internal/modules/cjs/loader.js:834:11)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)
Error: Error: spawn git ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:240:19)
    at onErrorNT (internal/child_process.js:415:16)
    at process._tickCallback (internal/process/next_tick.js:63:19)
    at Function.Module.runMain (internal/modules/cjs/loader.js:834:11)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)

tasklog_18.log

YAML Definition

steps:
- task: richardfennellBM.BM-VSTS-WIKIUpdater-Tasks.WikiFolderUpdaterTask.WikiFolderUpdaterTask@1
  displayName: 'Upload Release Notes to Technical Docs Wiki'
  inputs:
    repo: 'dev.azure.com/********/********/_git/TechnicalDocs.wiki'
    targetFolder: 'Environments\$(Release.EnvironmentName)\Releases\'
    sourceFolder: '$(Agent.TempDirectory)'
    Filter: '**/$(Release.ReleaseName)*.md'
    message: 'Auto-generated release notes for $(Release.ReleaseName) attempt $(Release.AttemptNumber)'
    gitname: '$(Release.RequestedFor)'
    gitemail: '$(Release.RequestedForEmail)'
    useAgentToken: false
    user: ******
    password: '$(PAT)'
    injectExtraHeader: false

I am getting the same outcome no matter I am using username and PAT, OAUTH token, or if credentials are passed via Header.

Agent Info

I have successfully tested the same task group using both azure-hosted and self-hosted agents with out any problems using OAUTH token. All release notes were successful published to the same git repo.

Once tests were all good I have added the same taskgroup to stages for our production environments.

Self-hosted agents on both test and production environments are configured to run under local admin account as windows service.

PAT issued for agents have full access to Azure DevOps.

Other info

@ipavlovi ipavlovi added the bug label Jun 12, 2020
@rfennell
Copy link
Owner

Sounds like you have tried everything I can think of. But, interestingly I had a similar issue myself yesterday

  • uploader worked using OAUTH or a PAT if run on
    • a Microsoft Hosted agent
    • my private agent
  • however, on a clients private agent I got the same error you have seen.

We tried everything we could think of, with no luck finding a real solution.

In the end, and it was a work around, what we did was to add a separate agent stage to the pipeline stage to do the release generation and wiki upload and got this to be run by a hosted agent. Would this work for you?

But this is a workaround but not a solution.

This task uses Simple-Git to do the upload, the task just wrappers this. The only way I can think of to move this forward is to do some local testing of Simple-Git a failing agent. Unfortunately, I don't have access to such an agent.

@rfennell
Copy link
Owner

rfennell commented Jun 12, 2020

Oh, sorry forgot to say there is one thing extra to try switch on the inject header option to true. This can help if proxies are in the way. It was added to fix an issue for on premises TFS setups, but it is worth a try

@ipavlovi
Copy link
Author

ipavlovi commented Jun 12, 2020

Look like there is a work around the Git, at least if content should be published to AzureDevops Wiki

I can push new page to Wiki using PS and DevOps API but that is exactly what I wanted to avoid by using WIKIUpdater task.

I will keep on trying to find solution for the original problem

@ipavlovi
Copy link
Author

I have tried Inject Header option but it failed with the same error message

@ipavlovi
Copy link
Author

I think I have found the cause of the problem

Environment PATH variable had C:\Program Files\Git\cmd\ entry but C:\Program Files\Git\ was missing.

After Adding 'C:\Program Files\Git' to the path and restarting agent service deployment was successful.

I am not 100% sure yet. Let me check it on another environment as well before closing this issue

@ipavlovi
Copy link
Author

ipavlovi commented Jun 12, 2020

I was wrong.

The correct solution is to add C:\agent\externals\git\cmd to the Environment Path on agent machine. Previous solution will work only if Git is installed separately.

It seems that simple-git is sending git commands to console and console cannot resolve path to git.exe because it is not in the environment path.

@rfennell
Copy link
Owner

Thanks for the excellent analysis. I will add it to the wiki notes in a troubleshooting section

@rfennell
Copy link
Owner

New troubleshooting notes in WIKI with 1.12.3

@innonav-dev
Copy link

I was wrong.

The correct solution is to add C:\agent\externals\git\cmd to the Environment Path on agent machine. Previous solution will work only if Git is installed separately.

It seems that simple-git is sending git commands to console and console cannot resolve path to git.exe because it is not in the environment path.

We have the exact same problem here. Git is missing in the enviroment path variable. Can someone tell me, how I can add the Git-Path to the agent path variable?

@rfennell
Copy link
Owner

rfennell commented Feb 1, 2021

I assume you are using the hosted agents, as if it is private agent you can just update the path in the standard manner via the control panel for all users.

If it is hosted agent, then you need to make the change at runtime. The path is only an environmental variable, so you could try the process outlined here

@innonav-dev
Copy link

No, we are using private agents. I assume we are talking about the System capabilities of the agent, right?
When I navigate to our Agent pools and then check agents capabilities, the Path variable doesn't contain a path to the git directory. And I can't update any variable in this control panel, since everything is locked. Am I trying to fix it in the wrong place?

@rfennell
Copy link
Owner

rfennell commented Feb 1, 2021

You can use the Windows UI to edit the path for all users

  1. Right click 'My Computer' and select 'Properties'.
  2. Click 'Advanced System Settings' link.
  3. Click 'Advanced' tab.
  4. Click 'Environment Variables...' button.

You can set the path here for all users on that machine

@innonav-dev
Copy link

So I was completely wrong :D Works like a charm now. Thank you.

@phil-w
Copy link

phil-w commented Jan 31, 2022

In case it helps anyone, I had this in a pipeline when using an Ubuntu VM, and the easiest fix was to switch to windows-latest, because that latter has the path to GIT already set up.

@ddprince-pro
Copy link
Contributor

Maybe I'm not commenting in the right issue, but I'm also facing the same problem, but under an Ubuntu Hosted Agent. Any plan to make this task work on Linux? I know using the image windows-latest is the workaround, but we're trying to exclusively use linux machines inside our build agents to reduce the overall execution time.

@rfennell
Copy link
Owner

rfennell commented Feb 8, 2023

@ddprince-yaksa you have a new issue it is best to start a new discussion or issue with details of your problem.

This thread was about the WIKI Updater, this already support Windows, Linux and Max agents - but this that the task you are using?

@ddprince-pro
Copy link
Contributor

@rfennell yes this is the task we're using. I'm having the issue described here under an Ubuntu agent. I can open a new issue if you want!

@rfennell
Copy link
Owner

rfennell commented Feb 8, 2023

So your problem is that the task cannot fine the instance of the Git command line tool?

I assume this is on an on premise Ubuntu agent, as I have tested this task with the Microsoft hosted Ubuntu agents. If that is the case, the fix is the same a Windows, make sure Git is installed on the agent and it is in the path

If that does not sort it, might be best to log a new issues with a details debug log (run with the variable system.debug=true set)

@ddprince-pro
Copy link
Contributor

@rfennell this is not an on premise agent, we're using the Microsoft Hosted Agent. I'm currently getting the details and I can get back to you. Which information from the debug output would you like to see?

@rfennell
Copy link
Owner

rfennell commented Feb 8, 2023

The whole debug output for the task, the following is what I expect to see for a Ubuntu agent

##[debug]updateOrderFile=true
##[debug]orderFilePath=undefined
##[debug]injecttoc=False
Variable: Repo [dev.azure.com/richardfennell/Git%20project/_git/Git-project.wiki]
Variable: Filename [TestPageWithCreds-10703.md]
Variable: Contents [Header
---
**Build Number**: 10703`n**Build Trigger PR Number**: `n`n# Global list of WI (0)`n`n# Global list of CS (1)`n### Associated commits  (only shown if CS) `n* ** ID6b7059ed94faa2e0105fe4ad9b4784bbb7ff472d**`n  -  **Message:** Documentation update (#1472)`n  -  **Commited by:** rfennell`n
---
Footer]
Variable: Commit Message [Update from Release - $(Release.ReleaseName) with Creds]
Variable: Git Username [builduser]
Variable: Git Email [build@demo]
Variable: Use Agent Token [false]
Variable: Replace File [true]
Variable: Append to File [true]
Variable: Username [richardfennell]
Variable: Password [*****]
Variable: LocalPath [D:\a\1\s\azurerepowithcreds]
Variable: Data Is File [false]
Variable: SourceFile [undefined]
Variable: Tag Repo [false]
Variable: Tag [undefined]
Variable: Branch [undefined]
Variable: InjectExtraHeader [false]
Variable: SslBackend [undefined]
Variable: Retries [5]
Variable: trimLeadingSpecialChar [false]
Variable: fixLineFeeds [true]
Variable: fixSpaces [false]
Variable: insertLinefeed [false]
Variable: updateOrderFile [true]
Variable: prependEntryToOrderFile [false]
Variable: orderFilePath [undefined]
Variable: injecttoc [false]
The provided repo URL is dev.azure.com/richardfennell/Git%20project/_git/Git-project.wiki
The protocol is https
The provided repo URL is dev.azure.com/richardfennell/Git%20project/_git/Git-project.wiki
Trimmed the URL to dev.azure.com/richardfennell/Git%20project/_git/Git-project.wiki
URL used https://richardfennell:***@dev.azure.com/richardfennell/Git%20project/_git/Git-project.wiki
Cleaned D:\a\1\s\azurerepowithcreds
Cloned dev.azure.com/richardfennell/Git%20project/_git/Git-project.wiki to D:\a\1\s\azurerepowithcreds
Set GIT values in D:\a\1\s\azurerepowithcreds
No sub-directory passed change to D:\a\1\s\azurerepowithcreds
Pull in case of post clone updates from other users
Working file name is TestPageWithCreds-10703.md
Created the 'TestPageWithCreds-10703.md' in 'D:\a\1\s\azurerepowithcreds' - fixing line-endings
Added TestPageWithCreds-10703.md to repo D:\a\1\s\azurerepowithcreds
Using the file - D:\a\1\s\azurerepowithcreds/.order
Attempting to updating the existing .order file
Appending entry to the .order file
Added .order file to repo D:\a\1\s\azurerepowithcreds
##[debug]Committing the changes with the message: Update from Release - $(Release.ReleaseName) with Creds
Committed file "D:\a\1\s\azurerepowithcreds" with message "Update from Release - $(Release.ReleaseName) with Creds" as SHA ead54bbd8764e79031ef6dedc645bbfcfde25d9e
Attempt 1 - Push to dev.azure.com/richardfennell/Git%20project/_git/Git-project.wiki
Push completed
Finishing: Git based WIKI Updater - Azure DevOps with Creds update .order file

@ddprince-pro
Copy link
Contributor

ddprince-pro commented Feb 8, 2023

@rfennell please see attached.
93.txt

I confirm the following agent is used for the task:
Pool: Azure Pipelines
Image: ubuntu-latest
Agent: Hosted Agent

@rfennell
Copy link
Owner

rfennell commented Feb 9, 2023

@ddprince-yaksa this is getting too complex to handle in a side chat - now being tracked in #1473

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

No branches or pull requests

5 participants