このタスクを使用して、Twine を使用して Python ディストリビューションのアップロードを認証します。 twine upload コマンドに -r FeedName/EndpointName --config-file $(PYPIRC_PATH)
を追加します。 この組織に存在するフィードの場合は、リポジトリ (-r
) としてフィード名を使用します。 それ以外の場合は、サービス接続で定義されているエンドポイント名を使用します。
構文
# Python twine upload authenticate v1
# Authenticate for uploading Python distributions using twine. Add '-r FeedName/EndpointName --config-file $(PYPIRC_PATH)' to your twine upload command. For feeds present in this organization, use the feed name as the repository (-r). Otherwise, use the endpoint name defined in the service connection.
- task: TwineAuthenticate@1
inputs:
# Feeds and Authentication
#artifactFeed: # string. My feed name (select below).
#pythonUploadServiceConnection: # string. Feed from external organizations.
# Python twine upload authenticate v1
# Authenticate for uploading Python distributions using twine. Add '-r FeedName/EndpointName --config-file $(PYPIRC_PATH)' to your twine upload command. For feeds present in this organization, use the feed name as the repository (-r). Otherwise, use the endpoint name defined in the service connection.
- task: TwineAuthenticate@1
inputs:
# Feeds and Authentication
#artifactFeed: # string. My feed (select below).
#pythonUploadServiceConnection: # string. Feed from external organizations.
入力
[マイ フィード名] を artifactFeed
- (下を選択)
string
.
Twine で認証する Azure アーティファクトのフィード名を指定します。 認証フィードは組織内に存在する必要があります。 プロジェクト スコープのフィードの場合は、構文 projectName/feedNameSelect
を使用します。
[マイ フィード artifactFeed
- (下を選択)
string
.
Twine で認証する Azure アーティファクトのフィード名を指定します。 認証フィードは組織内に存在する必要があります。 プロジェクト スコープのフィードの場合は、構文 projectName/feedNameSelect
を使用します。
外部組織からの pythonUploadServiceConnection
- フィード
string
.
twine サービス接続、twine で認証する外部組織の名前です。 エンドポイントに格納されている資格情報には、パッケージのアップロードアクセス許可が必要です。
タスク コントロールのオプション
すべてのタスクには、タスク入力に加えて制御オプションがあります。 詳細については、「コントロール オプションと一般的なタスク プロパティを参照してください。
出力変数
なし。
注釈
ビルドのスコープの PYPIRC_PATH
環境変数に twine
資格情報を提供します。 これにより、ビルドから twine
を含むフィードに Python パッケージを発行できます。
- パイプラインでこのタスクを実行する必要がある場合
- エージェントが Web プロキシの背後にあります。 TwineAuthenticate は、プロキシを使用するように twine を設定しますか?
- パイプラインが別のプロジェクト のフィードにアクセスする必要がある
パイプラインでこのタスクを実行する必要があるタイミング
Twine を使用して、認証されたパッケージ ソース (Azure Artifacts など) に Python ディストリビューションをアップロードする前に、このタスクを実行する必要があります。 他の順序付け要件はありません。 このタスクを複数回呼び出した場合、資格情報はスタックされません。 タスクを実行するたびに、以前に保存されていた資格情報が消去されます。
エージェントが Web プロキシの背後にあります。 TwineAuthenticate は、プロキシを使用するように twine を設定しますか?
いいえ。 このタスク自体は、エージェントが を使用するように構成されているWeb プロキシの背後で機能しますが、プロキシを使用するように twine を構成しません。
パイプラインが別のプロジェクトのフィードにアクセスする必要がある
パイプラインがフィードをホストしているプロジェクトとは異なるプロジェクトで実行されている場合は、他のプロジェクトを設定して、ビルド サービスへの読み取り/書き込みアクセスを許可する必要があります。 詳細については、Azure Pipelines でのパッケージのアクセス許可の に関するページを参照してください。
例示
次の例は、Python ディストリビューションを Azure Artifacts フィードと公式の Python レジストリに発行する方法を示しています。
- Azure Artifacts フィードへの Python ディストリビューションの発行
- 公式の Python レジストリ に Python ディストリビューションを発行する
Python ディストリビューションを Azure Artifacts フィードに発行する
この例では、プライベート Azure Artifacts フィードに発行するための認証を設定しています。 認証タスクは、フィードにディストリビューションを発行するために必要な認証資格情報を含む .pypirc
ファイルを作成します。
# Install python distributions like wheel, twine etc
- script: |
pip install wheel
pip install twine
# Build the python distribution from source
- script: |
python setup.py bdist_wheel
- task: TwineAuthenticate@1
displayName: Twine Authenticate
inputs:
# In this case, name of the feed is 'myTestFeed' in the project 'myTestProject'. Project is needed because the feed is project scoped.
artifactFeed: myTestProject/myTestFeed
# Use command line script to 'twine upload', use -r to pass the repository name and --config-file to pass the environment variable set by the authenticate task.
- script: |
python -m twine upload -r myTestFeed --config-file $(PYPIRC_PATH) dist/*.whl
フィードのスコープがプロジェクトの場合、artifactFeed
入力にはプロジェクトとフィード名が含まれます。 フィードが組織スコープの場合は、フィード名のみを指定する必要があります。
詳細については、こちらを参照してください。
Python ディストリビューションを公式の Python レジストリに発行する
この例では、公式の Python レジストリに発行するための認証を設定しています。 pypi の ツイン サービス接続 エントリ作成します。 認証タスクでは、そのサービス接続を使用して、ディストリビューションの発行に必要な認証資格情報を含む .pypirc
ファイルを作成します。
# Install python distributions like wheel, twine etc
- script: |
pip install wheel
pip install twine
# Build the python distribution from source
- script: |
python setup.py bdist_wheel
- task: TwineAuthenticate@1
displayName: Twine Authenticate
inputs:
# In this case, name of the service connection is "pypitest".
pythonUploadServiceConnection: pypitest
# Use command line script to 'twine upload', use -r to pass the repository name and --config-file to pass the environment variable set by the authenticate task.
- script: |
python -m twine upload -r "pypitest" --config-file $(PYPIRC_PATH) dist/*.whl