Bitbucket Pipelines を使い始める

Bitbucket Pipelines は、Bitbucket に組み込みの、統合された CI / CD サービスです。リポジトリの構成ファイルに基づいてコードを自動的にビルド、テスト、およびデプロイできます。基本的に、クラウド内にコンテナが作成されます。ユーザーはこれらのコンテナ内でコマンドを実行し (ローカル マシンの場合と同様)、要件に合わせてカスタム構成を行ってフレッシュなシステムのメリットを活用できます。

To set up Pipelines you need to create and configure the bitbucket-pipelines.yml file in the root directory of your repository. This file is your build configuration, and using configuration-as-code means it is versioned and always in sync with the rest of your code.

The bitbucket-pipelines.yml file holds all the build configurations for your repository. YAML is a file format that is easy to read, but writing it requires care. Indenting must use spaces, as tab characters are not allowed.

There is a lot you can configure in the bitbucket-pipelines.yml file, but at its most basic the required keywords are:

pipelines: contains all your pipeline definitions.

defaultcontains the steps that run on every push.

step: each step starts a new Docker container with a clone of your repository, then runs the contents of your script section.

script: a list of commands that are executed in sequence.

ステップ 1: 言語テンプレートを選択する

Pipelines can build and test anything that can run on Linux as we run your builds in Docker containers. We've provided templates in Bitbucket to help you get started with popular languages and platforms: PHP, JavaScript/Node.js (npm), Java (Maven/Gradle), Python, Ruby, C#, C++ (make) and more.

image showing pipelines navigation

  1. 左側のナビゲーション バーから [Pipelines] を選択します。
  2. 使用したい言語テンプレートを選択します。 

Don't see your language? Don't worry, there is always the Other option in the More menu if you can't see what you need. This uses our default Docker image that contains many popular build tools, and you can add your own using apt-get commands in your script.

ステップ 2: パイプラインを構成する

You'll need to edit the bitbucket-pipelines.yml file to include the commands required to build your software. You can also use pipes, found in the right hand side of the editor, to quickly add in popular configurations.

Picture of the editor

  1. Use the editor to customize the file to suit your needs. There are some basic examples below.


    コンテナの python のバージョンをチェックするためのコマンドを実行する基本的な構成は、次のようになります。

        - step:
              - python --version

    You can replace the contents of the script section with the commands you use to build and test. If you have quite a few commands to run, you might like to put them in a separate script file, and call that within your step. Also, if your test reports end up in an expected directory, you'll see the output of any failed tests in the logs.

    コードをビルドおよびテストした後、ステージング環境にビルドをデプロイする別の手順が必要な場合があります。これは手動でトリガーできるようになっているため、Pipelines ページでボタンをクリックしてデプロイできます。

        - step:
            name: Build and test
              - python
        - step:
            name: Deploy to staging
            trigger: manual
            deployment: staging
              - python


  2. 編集内容に満足し、最初の Pipeline を実行する準備が整ったら、[ファイルのコミット] を選択します。



To get the most out of pipelines, you can add more to the bitbucket-pipelines.yml file. For example, you can define which Docker image you'd like to use for your build, create build configurations for specific branches, tags, and bookmarks, make sure any test reports are displayed or define which artifacts you'd like to pass between steps.



最終更新日: 2019 年 2 月 28 日




Powered by Confluence and Scroll Viewport.