Issue with working dir when deploying AzurewebApp Azure Repos (hugo app)

BGBSAV 20 Reputation points
2023-10-12T12:08:55.94+00:00

Hi,

When deploying this through Azure Devops with pipelines we get the following:

Failed to read Git log: fatal: detected dubious ownership in repository at '/working_dir'
To add an exception for this directory, call:

	git config --global --add safe.directory /working_dir

Our Pipeline looks like this:

name: Azure Static Web Apps CI/CD


pr:
  branches:
    include:
      - main
trigger:
  branches:
    include:
      - main

jobs:
- job: build_and_deploy_job
  displayName: Build and Deploy Job
  condition: or(eq(variables['Build.Reason'], 'Manual'),or(eq(variables['Build.Reason'], 'PullRequest'),eq(variables['Build.Reason'], 'IndividualCI')))
  pool:
    vmImage: ubuntu-latest
  variables:
  - group: Azure-Static-Web-Apps-ashy-ground-0a0ce9a03-variable-group
  steps:
  - checkout: self
    submodules: true
  - task: AzureStaticWebApp@0
    env:
      PRE_BUILD_COMMAND: git config --global --add safe.directory /github/workspace
    inputs:
      azure_static_web_apps_api_token: $(AZURE_STATIC_WEB_APPS_API_TOKEN_ASHY_GROUND_0A0CE9A03)
###### Repository/Build Configurations - These values can be configured to match your app requirements. ######
# For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig
      app_location: "/" # App source code path
      api_location: "" # Api source code path - optional
      output_location: "public" # Built app content directory - optional
###### End of Repository/Build Configurations ######
    


Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,930 questions
0 comments No comments
{count} votes

Accepted answer
  1. Grmacjon-MSFT 19,151 Reputation points Moderator
    2023-10-18T08:26:44.61+00:00

    Hi @BGBSAV ,

    Are you the owner of the directory? the error you're getting is usually caused by a discrepancy between a user running the Git command and the owner of the directory where the repository is located.

    Based on your pipeline configuration, it looks like you already added a PRE_BUILD_COMMAND to set a safe.directory in Git’s global configuration:

    env:
      PRE_BUILD_COMMAND: git config --global --add safe.directory /github/workspace
    

    However, the error message suggests that Git is detecting incorrect ownership at /working_dir. I suggest trying the following:

    1. move the PRE_BUILD_COMMAND env variable to run before the Azure static web app deployment task.
    2. adjust your PRE_BUILD_COMMAND to add /working_dir This command tells Git to skip the ownership check for /working_dir, which should resolve the issue.
    env:
      PRE_BUILD_COMMAND: git config --global --add safe.directory /working_dir
    

    Please let us know if you have further questions.

    -Grace


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.