git Azure部署失败,原因如下:'fatal:在存储库中检测到可疑的所有权

9avjhtql  于 12个月前  发布在  Git
关注(0)|答案(2)|浏览(139)

我正在使用ASP.NET应用程序,并使用Azure和Git进行部署。它被设置为在Master分支被推送到时触发部署。
我过去成功地做到了这一点,但现在失败了。我可以成功地将我的代码推送到GitHub,每次都出现在那里,但它无法在Azure上部署。
从部署中心,我看到提交id以“temp”开头,如“temp-XXXXXX”。它还会在日志详细信息中留下一条错误消息,内容如下:

"fatal: detected dubious ownership in repository at _______ is owned by: ________ 
but the current owner is _______. 

git config --global --add safe.directory '%(prefix)///____________________'\n\r\nC:\Program Files\Git\cmd\git.exe 
remote add -t master origin "[email protected]:_____"

(The空白的信息是完整的IP地址与子目录和存储库名称,我不认为这很重要,因为这似乎是一个通用的问题)
我尝试使用safe.directory提供的确切命令将父目录添加到safe.directory,但收到错误“no such file or directory:%(前缀)/__。
根据我的本地文件系统,我已经是目录的所有者。
我试着按照this question的答案中列出的一些步骤进行操作,但我不愿意执行git config --global --add safe.directory '*',因为它是一个共享存储库。
这个问题会不会是Azure本身造成的?我是否需要以某种方式授予Azure权限?
谢谢

nlejzf6q

nlejzf6q1#

为了提供更新,发现了一个错误。我们的产品工程团队已经推出了修复程序。(来源:Microsoft Q&A My Answer)

wixjitnu

wixjitnu2#

  • 我建议使用以下步骤:-*

请确保运行此命令以将存储库添加到安全列表中,如下所示:-

git config --global --add safe.directory 'C:\Users\sid24desai\source\repos\WebApplication6'
  • 然后通过添加正确的git远程url来再次尝试推送代码,如下所示:-*
git remote -v
git remote set-url origin https://github.com/sid24desai/WebApplication6

为了解决错误检查此SO thread answer由Stinn和halt 9 k

然后,我尝试在Azure Web应用中部署示例**.NET application,使用.NET 6.0 framework**,并成功部署,如下所示:-

我的github动作流程:-

name: Build and deploy ASP.Net Core app to Azure Web App - valleywebapp832

on:
  push:
    branches:
      - master
  workflow_dispatch:

jobs:
  build:
    runs-on: windows-latest

    steps:
      - uses: actions/checkout@v2

      - name: Set up .NET Core
        uses: actions/setup-dotnet@v1
        with:
          dotnet-version: '6.0.x'
          include-prerelease: true

      - name: Build with dotnet
        run: dotnet build --configuration Release

      - name: dotnet publish
        run: dotnet publish -c Release -o ${{env.DOTNET_ROOT}}/myapp

      - name: Upload artifact for deployment job
        uses: actions/upload-artifact@v2
        with:
          name: .net-app
          path: ${{env.DOTNET_ROOT}}/myapp

  deploy:
    runs-on: windows-latest
    needs: build
    environment:
      name: 'Production'
      url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}

    steps:
      - name: Download artifact from build job
        uses: actions/download-artifact@v2
        with:
          name: .net-app

      - name: Deploy to Azure Web App
        id: deploy-to-webapp
        uses: azure/webapps-deploy@v2
        with:
          app-name: 'valleywebapp832'
          slot-name: 'Production'
          publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_CD4EC59DD26349C09FBA41C085A9BEBF }}
          package: .

相关问题