Bitbucket Pipelines を使い始める

Bitbucket Pipelines is an integrated CI/CD service, built into Bitbucket. It allows you to automatically build, test and even deploy your code, based on a configuration file in your repository.

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.

Step 1: Choose a language template

Pipelines can build and test anything that can run on Linux as we run your builds in Docker containers. We've provided templates 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.

  1. Select Pipelines from the left hand navigation bar.
  2. Select the language template you'd like to use. 

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.




Step 2: Configure your pipelines

You'll need to edit the bitbucket-pipelines.yml file to include the commands required to build your software.

  1. Use the editor to customize the file to suit your needs.

    Browse some example configurations

    Here's a very basic configuration that runs a command to check the version of python in the container:

    pipelines:
      default:
        - step:
            script:
              - 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.

    After you've built and tested your code, you might want another step which deploys your build to a staging environment. We'll make it manually triggered, so you can deploy at the click of a button on the Pipelines page:

    pipelines:
      default:
        - step:
            name: Build and test
            script:
              - python build-test.py
        - step:
            name: Deploy to staging
            trigger: manual
            deployment: staging
            script:
              - python deploy.py

    We also have more information on how to configure this file.

  2. Select Commit file when you are happy with your edit and ready to run your first Pipeline.

You've now created your default pipeline. Wahoo! 

Pipelines will now automatically trigger whenever you push changes to your repository running the default 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, or create build configurations for specific branches, tags, and bookmarks.




What's next?

Now that you've got the basics, check out our main page to learn more about all the ways you can configure your pipeline.

最終更新日 2018 年 3 月 1 日

この翻訳に満足しましたか?

はい
いいえ
この記事についてのフィードバックを送信する

このセクションの項目

Powered by Confluence and Scroll Viewport.