概要
手動ではなく master push 時にパイプラインを実行する方法を紹介します
環境
- bitbucket (2025/05/29時点)
bitbucket-pipelines.yml
image: python:3.12.10
pipelines:
branches:
master:
- step:
name: Install packages and Lint code
caches:
- pip
script:
- pip install pipenv
- pipenv install -d
- pipenv run isort --check --diff .
- pipenv run black --check .
基本はイメージを選択しあとは実行するコマンドを並べていけば OK です
ビルドが失敗すると自動でメールが送信されます
初回は必ず手動で実行する必要がありそう
bitbucket-pipelines.yml 追加後に
- 左メニュー -> パイプライン -> Run initial pipeline
で必ず初回は手動実行する必要がありそうです
次回以降は push 時に自動で実行されます
ダメなパターン
pipenv install と pipenv run のステップをわけるとうまくインストールしたパッケージが次に渡らないので素直に同じステップ内で実行しましょう
image: python:3.12.10
pipelines:
branches:
master:
- step:
name: Install packages
caches:
- pip
script:
- pip install pipenv
- which pipenv
- pipenv install -d
artifacts:
- /usr/loca/bin/
- /root/.local/share/virtualenvs/
- step:
name: Lint code
script:
- pipenv run isort --check --diff .
- pipenv run black --check .
最後に
bitbucket の無料枠でも毎月50分であればパイプラインのランナーを使えます
bitbucket の場合作成された pipeline の履歴は消せないようです
0 件のコメント:
コメントを投稿