简体   繁体   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. Used twine to authenticate and publish my Python packages to an Azure Artifacts feed 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. Although it ran successfully, but I didn't get any package in Artifacts. B、虽然运行成功了,但是我在Artifacts里面没有得到任何包。 I found the 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 Warning:'D:\\a\\1\\a' is empty. Nothing will be added to build artifact

C. I did some research and decided to add additional section which does a copy and publish 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?

Different Tried things after Suggestions:建议后的不同尝试:

  1. Add Tree command to see all build folders to confirm generation of file:添加Tree 命令以查看所有构建文件夹以确认文件的生成:

在此处输入图片说明

2. After removing source folder and let it use default source 2.删除source folder ,让它使用默认源在此处输入图片说明

successful build and consumed:成功构建和消费: 在此处输入图片说明

Artifacts is generated and I can see it from pipeline.工件已生成,我可以从管道中看到它。 在此处输入图片说明

Problem Statement问题陈述

In Artifacts tab, I don't see the build available in any feed.在 Artifacts 选项卡中,我没有在任何提要中看到可用的构建。 How to connect the build with a specific feed (ddey-feed).如何将构建与特定提要 (ddey-feed) 连接起来。 I though TwineAuthenticate is suppose to take care of it.我虽然TwineAuthenticate应该会处理它。

在此处输入图片说明

ok.行。 I have finally resolved the whole issue and could deploy the package to Artifacts Feed.我终于解决了整个问题,可以将包部署到 Artifacts Feed。

Key learning:重点学习:

  • When creating Artifacts Feed, Make sure to check permission.创建 Artifacts Feed 时,请务必检查权限。 Add Allow project-scoped builds otherwise will get permission error in pushing package from Azure pipeline添加Allow project-scoped builds否则在从 Azure 管道推送包时会出现权限错误
  • You need to define PYPIRC_PATH to point where .pypirc file reside.您需要定义PYPIRC_PATH以指向 .pypirc 文件所在的位置。 This can be done using environment variable set-up as shown below这可以使用环境变量设置来完成,如下所示
- 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)
  • Make sure Twine Authenticate feed name matches with twine upload feed name.确保Twine Authenticate提要名称与twine upload提要名称匹配。 If pipeline fails to push the package, you can try to run following command directly from your repo: twine upload -r ddey-feed --config-file ./.pypirc dist/ and it should successfully upload the build to Artifacts.如果管道无法推送包,您可以尝试直接从您的存储库运行以下命令: twine upload -r ddey-feed --config-file ./.pypirc dist/并且它应该成功地将构建上传到 Artifacts。

  • For debug purpose, print the directories.出于调试目的,打印目录。

     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)"
  • Summary of components of the pipeline管道组件总结

在此处输入图片说明

Indentation before CopyFiles@2 CopyFiles@2 前的缩进在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM