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

Error: spawn git ENOENT #1583

Closed
rodunola opened this issue Jan 10, 2024 · 3 comments
Closed

Error: spawn git ENOENT #1583

rodunola opened this issue Jan 10, 2024 · 3 comments

Comments

@rodunola
Copy link

Azure DevOps Extensions

WIKI Updater

Platform

Azure DevOps Server (TFS) - Specify Version

Azure DevOps Server (TFS) Version

No response

Extension Version

No response

Describe the bug

I am trying to update our wiki with the latest release notes during our release pipeline, and I cannot get it to work for me. I continually get the "Error: spawn git ENOENT" error.
I am using a self-hosted agent (windows) and using TFS along with TFVC.

I have tried:

  1. Add C:\agent\externals\git\cmd to the Environment Path on agent machine.
  2. Set InjectExtraHeader parameter to true
  3. Set UseAgentToken parameter to true
  4. Remove https:// and domain from "repo URL to clone"

Repo Steps

  1. Add "Git based WIKI Single File Updater from Black Marble"
  2. Fill out settings
  3. Check "Run with Build Agent Credentials"
  4. Create Release

Expected Behavior

Expected to write to the wiki

Logging Information

##[error]Error: Error: spawn git ENOENT
at Process.ChildProcess._handle.onexit (node:internal/child_process:283:19)
at onErrorNT (node:internal/child_process:478:16)
at processTicksAndRejections (node:internal/process/task_queues:83:21)
##[debug]Processed: ##vso[task.issue type=error;]Error: Error: spawn git ENOENT
at Process.ChildProcess._handle.onexit (node:internal/child_process:283:19)
at onErrorNT (node:internal/child_process:478:16)
at processTicksAndRejections (node:internal/process/task_queues:83:21)
##[debug]task result: Failed
##[error]Error: Error: spawn git ENOENT
at Process.ChildProcess._handle.onexit (node:internal/child_process:283:19)
at onErrorNT (node:internal/child_process:478:16)
at processTicksAndRejections (node:internal/process/task_queues:83:21)
##[debug]Processed: ##vso[task.issue type=error;]Error: Error: spawn git ENOENT
at Process.ChildProcess._handle.onexit (node:internal/child_process:283:19)
at onErrorNT (node:internal/child_process:478:16)
at processTicksAndRejections (node:internal/process/task_queues:83:21)
##[debug]Processed: ##vso[task.complete result=Failed;]Error: Error: spawn git ENOENT
at Process.ChildProcess._handle.onexit (node:internal/child_process:283:19)
at onErrorNT (node:internal/child_process:478:16)
at processTicksAndRejections (node:internal/process/task_queues:83:21)

@rfennell
Copy link
Owner

That error is usually due to the task not being able to spawn the git.exe command, most commonly due to a PATH issue.

On the self hosted agent open a command prompt and see if you can run git and get the usage mesage

image

If you sort out the path, the git command should work for the command prompt and the task

Also see #1474

@rodunola
Copy link
Author

Thank for your quick response. I added multiple paths and restarted the agent service on the build machine. Now I face another issue:
##[error]Error: Cloning into 'C:\Agents\3.220.5_work\19\a\repo'...
remote: TF401019: The Git repository with name or identifier WRGDepot does not exist or you do not have permissions for the operation you are attempting.
fatal: repository 'https://devops.xxxxx.org/Extant/WRGDepot/_git/WRGDepot/' not found

  1. I allowed the pipeline to access the OAUTH Token.
  2. Enabled contribute, Create Tag and Read permission to

I noticed I cannot access "https://devops.xxxxx.org/Extant/WRGDepot/_git/WRGDepot" on the browser but I when I do a git clone, it's successful.

Got any ideas what could be wrong?

@rfennell
Copy link
Owner

URL Format

Firstly can I check if this is a standard Git repo or the Azure DevOps WIKI Git repo as they have different URL formats !!!!

See https://github.com/rfennell/AzurePipelines/wiki/WIKI-Updater-Tasks#url-required-to-clone-a-wiki-repo

This is a really common issue as this is not obvious

Test with a PAT

A good idea is to test the clone repo URL from within the task, and at the command line, you can use the PAT as opposed to the Agent Access Token see https://github.com/rfennell/AzurePipelines/wiki/WIKI-Updater-Tasks#authentication , set UseAgentToken: false and username and password.

If the PAT test work it shows the problem is the scope of the Agent Access Token, as noted in the WIKI

Agent Scope

If using OAUTH make sure that the 'Project Collection > Setting > Pipeline > Setting > Limit job authorization scope to referenced Azure DevOps repositories' as not enabled. If set it can block access to the target repo.

These setting options keep changing, so some experimentation can be required to find the set you need. Basically they control if the ' build service' account or the 'Project Collection build service` account is used for the Agent Access Token. So I suggest trying

  • Granting permissions to the repo for both <Project> build service' account and the 'Project Collection build service account
  • Try altering the Project Collection > Setting > Pipeline > Setting > Limit job authorization scope'
  • Once it is working tidy up to the security model you want

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

2 participants