我正在try 使用Azure管道将一个Python包发布到Artiact的提要. 我可以在我的本地机器上这样做,并使用Twin上传包,但我有一个正在进行的身份验证问题.
trigger:
- main
pool:
vmImage: ubuntu-22.04
variables:
pip_cache_dir: '$(Pipeline.Workspace)/.pip_cache'
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '3.10'
addToPath: true
- bash: |
python -m venv worker_venv
source worker_venv/bin/activate
pip install --upgrade pip
pip install pipenv
pipenv requirements > requirements.txt
pipenv requirements --dev > requirements-dev.txt
pip install --cache-dir $(pip_cache_dir) -r ./requirements.txt
pip install --target="./.python_packages/lib/site-packages" --cache-dir $(pip_cache_dir) -r ./requirements.txt
displayName: 'Install tools'
- script: |
source worker_venv/bin/activate
python setup.py sdist bdist_wheel
displayName: 'Build package'
- task: TwineAuthenticate@1
inputs:
artifactFeed: sample-feed-01
- script: |
source worker_venv/bin/activate
python -m twine upload --verbose --config-file $(PYPIRC_PATH) --repository-url https://pkgs.dev.azure.com/**company**/Platform/_packaging/sample-feed-01/pypi/upload/ dist/*
env:
TWINE_USERNAME: "azure"
TWINE_PASSWORD: $(PYPI_TOKEN)
displayName: 'Upload package to Azure Artifacts'
我try 了所有方法,包括GPT-4,但解决方案似乎是错误的或过时的. 这就是错误:
/usr/bin/bash --noprofile --norc /home/vsts/work/_temp/75d0c60b-0c2a-44e9-be0f-29d838a3b86e.sh
Uploading distributions to
https://pkgs.dev.azure.com/**company**/Platform/_packaging/sample-feed-01/pypi/up
load/
INFO dist/**package**.whl (2.6 KB)
INFO dist/**package**.tar.gz (2.6 KB)
INFO username set by command options
INFO password set by command options
INFO username: azure
INFO password: <hidden>
Uploading **package**.whl
25l
0% ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 0.0/5.7 kB • --:-- • ?
100% ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 5.7/5.7 kB • 00:00 • ?
100% ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 5.7/5.7 kB • 00:00 • ?
25hINFO Response from
https://pkgs.dev.azure.com/**company**/Platform/_packaging/sample-feed-0
1/pypi/upload/:
401 Unauthorized
INFO {"$id":"1","innerException":null,"message":"TF400813: The user
'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa' is not authorized to access this
resource.","typeName":"Microsoft.TeamFoundation.Framework.Server.Unauth
orizedRequestException,
Microsoft.TeamFoundation.Framework.Server","typeKey":"UnauthorizedReque
stException","errorCode":0,"eventId":3000}
ERROR HTTPError: 401 Unauthorized from
https://pkgs.dev.azure.com/**company**/Platform/_packaging/sample-feed-0
1/pypi/upload/
Unauthorized
我对'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa'
作为用户名有一些怀疑,我没有混淆它,这就是我在管道中看到的.
如有任何帮助,我们将不胜感激