[英]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:建议后的不同尝试:
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:重点学习:
Allow project-scoped builds
otherwise will get permission error in pushing package from Azure pipeline添加Allow project-scoped builds
否则在从 Azure 管道推送包时会出现权限错误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管道组件总结
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.