パイプラインのアーティファクト

はじめに

アーティファクトは、ステップによって作成されるファイルです。パイプライン設定で定義したら、以降のステップで共有したり、エクスポートしてステップの完了後にアーティファクトを保持したりすることができます。たとえば、ビルド ステップで生成された JAR ファイルまたはレポートを、後のデプロイメント ステップで使用できます。ステップで生成されたアーティファクトをダウンロードしたり、外部ストレージにアップロードすることもできます。

次の点に留意する必要があります。

  • ステップの最後に BITBUCKET_CLONE_DIR にあるファイルをアーティファクトとして構成できます。BITBUCKET_CLONE_DIR は、リポジトリが最初にクローンされるディレクトリです。

  • glob パターンを使用してアーティファクトを定義できます。* で開始される glob パターンは、引用句で囲む必要があります。: これらは glob パターンのため、パス セグメント "." および “..” は使用できません。ビルド ディレクトリに相対的なパスを使用します。

  • アーティファクトのパスは、BITBUCKET_CLONE_DIR. の相対パスになります。

  • ステップ中に作成されたアーティファクトは、以降のすべてのステップで使用できます。

  • 並行ステップで作成されたアーティファクトは、同じ並行ステップのグループ内の他のステップからはアクセスできない場合があります。並行グループ内の別のステップがアーティファクトを要求した場合、要求された時点で存在する可能性もあれば、存在しない可能性もあります。

  • アーティファクトは生成から 14 日後に削除されます。

  • 初期設定では、使用可能なすべてのアーティファクトがステップの開始時にダウンロードされます。ステップによってアーティファクトをダウンロードするかどうかを制御するには、download フラグを指定します。

アーティファクトの使用

In the example bitbucket-pipelines.yml file that follows, we show how to configure artifacts to share them between steps.

  • "Build and test" スクリプトが完了すると、dist フォルダと report フォルダ (いずれも BITBUCKET_CLONE_DIR にあります) のすべての txt ファイルが同じパスでアーティファクトとして保持されます。

  • "Integration test" と "Deploy to beanstalk" は、最初のステップで作成された dist および reports のファイルにアクセスできます。

  • "Integration test" が dist または reports へのすべての変更は、"Integration test" でアーティファクトとして指定されていないため、後のステップでは利用できません。変更を保持したい場合、このステップでそれらもアーティファクトとして定義する必要があります。

  • アーティファクトはダウンロードされないため、「成功メッセージを表示」中は利用できません。このステップではアーティファクト success.txt が作成されて、後のステップでダウンロードできるようになります。

  • Artifacts that are downloaded in a given step have the default file permissions set as 644 (-rw-r--r--). These permissions may need to be changed depending on the commands being run, such as pipes.

Artifacts have a 1 GB size limit.

bitbucket-pipelines.yml の例

pipelines: default: - step: name: Build and test image: node:10.15.0 caches: - node script: - npm install - npm test - npm run build artifacts: # defining the artifacts to be passed to each future step. - dist/** - reports/*.txt   - step: name: Integration test image: node:10.15.0 caches: - node services: - postgres script: # using one of the artifacts from the previous step - cat reports/tests.txt  - npm run integration-test - step: name: Deploy to beanstalk image: python:3.5.1 script: - python deploy-to-beanstalk.py - step: name: Display success message artifacts: download: false # do not download artifacts in this step paths: # defining artifacts to be passed to each future step - success.txt script: - echo "Deployment successful!" > success.txt definitions: services: postgres: image: postgres:9.6.4

手動ステップ

手動ステップでは自動ステップと同様、過去のあらゆるステップで作成されたビルド アーティファクトが作業ディレクトリにコピーされます。

アーティファクトのダウンロードと有効期限

ステップで生成されたアーティファクトをダウンロードできます。

  1. パイプラインの結果ビューの [アーティファクト] タブを選択します。

  2. ダウンロード アイコンをクリックします。

アーティファクトは、アーティファクトを生成したステップの完了後 14 日間保持されます。この期間が過ぎるとアーティファクトは期限切れとなり、パイプラインでは以降のあらゆる手動ステップを実行できなくなります。

If you need artifact storage for longer than 14 days (or more than 1 GB), we recommend using your own storage solution, like Amazon S3 or a hosted artifact repository like JFrog Artifactory. Setting a reasonable time limit for build artifacts allows us to manage our costs so we don't have to charge for storage and transfer costs of build artifacts in Pipelines.

詳細については、次の情報をご参照ください。

さらにヘルプが必要ですか?

アトラシアン コミュニティをご利用ください。