簡體   English   中英

Azure DevOps Artifacts 中的 Python 包發布:“D:\\a\\1\\a”為空。 不會添加任何內容來構建工件

[英]Python Package publish in Azure DevOps Artifacts: 'D:\a\1\a' is empty. Nothing will be added to build artifact

A. 使用twine對我的 Python 包進行身份驗證並將其發布到 Azure Artifacts 源

     - task: CmdLine@2
        displayName: Build Artifacts
        inputs:
          script:
            echo Building distribution package
            python -m pip install --upgrade twine build setuptools
            python -m build 
      
      - task: TwineAuthenticate@1
        inputs:
          artifactFeed: ddey-feed
      - script:
          python -m twine upload -r "ddey-feed" --config-file $(PYPIRC_PATH) dist/*.whl

B、雖然運行成功了,但是我在Artifacts里面沒有得到任何包。 我發現Warning:'D:\\a\\1\\a' is empty. Nothing will be added to build artifact Warning:'D:\\a\\1\\a' is empty. Nothing will be added to build artifact

C. 我做了一些研究並決定添加額外的部分來copy and publish

          - task: CopyFiles@2
           displayName: 'Copy Files to: $(build.artifactstagingdirectory)'
           inputs:
            SourceFolder: '$(Build.SourcesDirectory)'
            Contents: |
              **/*
              !.git/**/*
            TargetFolder: '$(Build.ArtifactStagingDirectory)'
           condition: succeededOrFailed()
    
          - task: PublishBuildArtifacts@1
            displayName: 'Publish Artifact: drop'
            inputs:
            PathtoPublish: '$(build.artifactstagingdirectory)'
            condition: succeededOrFailed()

Can anyone please comment what else I can modify in yaml file to get the package available in Artifacts?

建議后的不同嘗試:

  1. 添加Tree 命令以查看所有構建文件夾以確認文件的生成:

在此處輸入圖片說明

2.刪除source folder ,讓它使用默認源在此處輸入圖片說明

成功構建和消費: 在此處輸入圖片說明

工件已生成,我可以從管道中看到它。 在此處輸入圖片說明

問題陳述

在 Artifacts 選項卡中,我沒有在任何提要中看到可用的構建。 如何將構建與特定提要 (ddey-feed) 連接起來。 我雖然TwineAuthenticate應該會處理它。

在此處輸入圖片說明

行。 我終於解決了整個問題,可以將包部署到 Artifacts Feed。

重點學習:

  • 創建 Artifacts Feed 時,請務必檢查權限。 添加Allow project-scoped builds否則在從 Azure 管道推送包時會出現權限錯誤
  • 您需要定義PYPIRC_PATH以指向 .pypirc 文件所在的位置。 這可以使用環境變量設置來完成,如下所示
- script: | echo "$(PYPIRC_PATH)" python -m twine upload -r ddey-feed --verbose --config-file $(PYPIRC_PATH) dist/* displayName: 'cmd to push package to Artifact Feed' env: PYPIRC_PATH: $(Build.SourcesDirectory)
  • 確保Twine Authenticate提要名稱與twine upload提要名稱匹配。 如果管道無法推送包,您可以嘗試直接從您的存儲庫運行以下命令: twine upload -r ddey-feed --config-file ./.pypirc dist/並且它應該成功地將構建上傳到 Artifacts。

  • 出於調試目的,打印目錄。

     echo "Structure of work folder of this pipeline:" tree $(Agent.WorkFolder)\\1 /f echo "Build.ArtifactStagingDirectory:" echo "$(Build.ArtifactStagingDirectory)" echo "Build.BinariesDirectory:" echo "$(Build.BinariesDirectory)" echo "Build.SourcesDirectory:" echo "$(Build.SourcesDirectory)"
  • 管道組件總結

在此處輸入圖片說明

CopyFiles@2 前的縮進在此處輸入圖片說明

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM